I built a php / Laravel project in CircleCI. I would like to run my tests with PHPunit. The problem is that all my tests that include request to my API result in 404.
It seems like test server doesn’t not exixts when i run PHPunit or whatever.
Did I have to do something special in order to make my request tests work ?
Thx for your responses.
It depends on a lot of things. Are you using Selenium or some other browser testing? Or are you using the Laravel testing system, so you’re not actually performing HTTP requests?
As is usual, readers would need to see code and/or logs in order to be able to help you.
Is this a problem you are experiencing locally, or just on CircleCI?
It’s a problem i’m only having on CircleCI.
I just use the Laravel testing system like that :
public function testIndexAsAdmin()
The test is ok in local, but when i run it on CircleCI the output is :
Expected status code 200, got 404.
Failed asserting that false is true.
It is surprising that you’re getting this problem, since the internal testing system in Laravel is intended to erase environmental differences (e.g. web server).
One approach you could take is to run this with the SSH option, let it fail, then try things in your tests to see if that helps them. It’s remarkable what one can do with
I don’t use Laravel, but that trailing slash looks awkward, so (for example) I would try removing that. Also, can you turn on an application-level logger to see what routes are triggered? Have a look in any general and PHP error logs on the server, of course.
Note that that SSH time eats into your build minutes, so remember to log off and Cancel the build in the UI.