I am currently writing tests for a back-end API using Laravel.
Some of the endpoints are not made yet and will throw:
InvalidArgumentException: Route [Route] not defined.
Is there a way to prevent it from completely stopping my tests and continue and give the information later about the failed tests?
I want to be able to capture that the response is not a defined route, and then make an if statement to determine if the route is defined or not (dependent on response).
This information will then be outputted somewhere else.
If the endpoints don't exist whatsoever yet, then consider writing them on a placeholder endpoint for now. This may limit the tests you can make, but it offers more in the long run.
If there are any existing endpoints that have similarities with the not-yet-made ones, then consider using that endpoint instead for now, constructing your tests based on those similar elements. i.e similar variables, structure, etc.
I want to be able to capture that the response is not a defined route, and then make an if statement to determine if the route is defined or not (dependent on response). This information will then be outputted somewhere else.
One can but it this way. If you are not following this principle.
Write the test (Red)
Make it pass (Green)
Refactor (or write another test)
Then you might not doing it properly.
Usually you should only write one test at the time and make it pass but when doing test inside out then you will have feature tests that are not passing while writing unit tests to make the feature test pass.
You can always run a single test or a single file with tests to prevent it from blowing up.
You write it out, it'll fail, you make it pass by meeting it's requirements, then you refactor. Repeat this.
All you need to do is define that route, if that's good enough to make the test pass, then you leave it at that, until it fails again, and that route needs to do something.
sometimes you need to make the endpoints for your android/ios guys.. if so then a mock response should be sent as that will show you and them what is needed.. ie great for planning
The issue with this is I am not the developer, but just a tester. So I am unable to "fix" at the same speed I am finding the issues/endpoints that do not exist. So I want a way to be able to determine if the endpoint is not made, and then if it isn't it will spit out some information later on, once the test has completed.
So while yes this is the ideal way to do it, I cannot do it. But thank you
@shez1983 Could you explain a bit more on this? I like the idea of a 'mock' response that "should" be returned. So that the dev team is able to see what needs to be made and what to use etc