Running php artisan test results in 3 failed, 4 skipped, 26 passed
Hey!
This is the first time I have run the php artisan test since working on the application (Laravel 8) and the result is
Tests: 3 failed, 4 skipped, 26 passed
I haven't touched anything in the tests folder ever which makes me think that these tests should actually be 100% passed no matter what, because they are provided out of the box and for reason. Here are the 3 failed tests
• Tests\Feature\RegistrationTest > new users can register
The user is not authenticated
Failed asserting that false is true.
• Tests\Feature\EmailVerificationTest > email can be verified
Failed asserting that two strings are equal.
• Tests\Feature\AuthenticationTest > users can authenticate using the login screen
The user is not authenticated
Failed asserting that false is true.
I have no idea how to fix these failed tests. What are they about? I can't clearly understand what's the meaning of them. What to do with the 4 skipped and why they are skipped?
Did you change any logic on the related controllers?
Or removed any of them, due to not using a feature, such the one which verifies emails?
Test cases test the code, even if you didn't touch the test cases before, but if you changed the code they are testing, some could fail due to the changes made.
You should run your test cases when making changes to your app, and then either fix your code if the changes break the test cases, or update the test cases directly affected by the changes, if the changes are about the test case's subjects.
@migsAV Yeah, I've changed some simple logic like where to redirect after login based on user type. Also added some additional columns to the users table.
The redirect change already explains the AuthenticationTest failure.
On the test case that is failing test_users_can_authenticate_using_the_login_screen, the last assertion checks if the response redirects the user to the path defined in RouteServiceProvider::HOME.
If you changed where the controller redirects after logging an user in, this assertion will fail until you fix it.
There are the kind of changes I referred to on my first answer. If you change the code being testes, most likely some tests will start failing.
• Tests\Feature\AuthenticationTest > users can authenticate using the login screen
Illuminate\Validation\ValidationException
The given data was invalid.
@laralex then you need to retrace your steps because you have changed something that is affecting your tests.
You mentioned you changed the redirect, this will affect your tests
@migsAV Yeah, I've changed some simple logic like where to redirect after login based on user type. Also added some additional columns to the users table.
You got to remember that a slight change in how the login works will sometimes cause failed tests