1 year ago

[closed] Laravel 5.7 TDD Routes flushed after first test method executed

Posted 1 year ago by alex_time

I am facing a strange behavior trying to explore the TDD world. I have made two test methods on the same test class. Each test method is isolated from others, in fact if I need a user logged in I have to log a user in every test method.

Here the issue: during the first test method execution I can query routes as many time as I need and I also can post or get or patch as many times I need; but when the first test method execute is terminated and Laravel try to execute the second method, all named routes are gone. Trying to understand why, I noticed that all the routes are completely flushed after the first test method and I cannot resolve any routes after the first test method. Even ifI try to post to a full path I get a Missing Route Exception.

If I try to filter the test method to execute, in that case the test work (and pass) with no problem, indicating that there is no issue with the test method itself, the problem is when I try to use the second test method only after a call the the very first is completed.

Please sign in or create an account to participate in this conversation.