You test for real also, I look at most test to identify places to refactor.
Just remember, you can have a "test" pass yet still have a real problem in the real method / function.
Summer Sale! All accounts are 50% off this week.
Ok, So i am just now attempting to learn how to do laravel testing on an existing project with many DB tables and data that needs to be inserted for the site to work. I'm working through a tutorial, but already it is giving me headaches.
First I had issues with the DB connection and refreshing data between test when migrations are in various sub folders. I think I solved this issue.
But then there's the issue of a DB refreshing with every test. Which i think could be solved with some sort of preset up system, which hopefully I'll learn later.
But currently with two simple tests:
class HomeTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testHomepageNotLoggedIn ()
{
$response = $this->get('/');
$response->assertSee('Search');
$response->assertStatus(200);
}
}
and
class HobbyTest extends TestCase
{
// use RefreshDatabase;
/**
* A basic test example.
*
* @return void
*/
public function testHobbyCategoriesExist ()
{
$response = $this->get('/browse');
$response->assertSee('Hobby Categories');
$response->assertSee('Animals');
$response->assertStatus(200);
}
}
the home test fails due to a route not being defined if the hobby test is included, but passes if i remove the hobby test.
I read in an old thread something about routes being required_once vs require. which did fix the problem, but if I have to go and change all this code for a bunch of issues such as this (often with hours of headache to figure out) I'm going to just give up on testing as it is not the site that is failing but nuances with the testing system.
What do I have to do to make this process smoother?
Again, DB structure already exists and some tables have predefined data. I will mainly need to just verify that CRUD operations work, and pages display as expected. I don't need it to refresh database after every test cause that will just take far to long to reseed and migrate. If I want a test to refresh, I can manually request that, right?
Please or to participate in this conversation.