Do you like testing? I like testing. Well, in fact I like testing once I have understood how the engine I am using works. Until this moment, everything is a completely disaster.
And because this learning curve, many of my personal projects have reached an MVP without any type of testing environment. And sincerely, I don’t really like this scenario.
Many years ago I was thinking about a simple and fast tool to test specific routes, expecting specific HTTP codes and providing an easy environment of ensuring properly your HTTP layer.
So… I present you Visithor, a PHP based library that provides you this functionality, with a simple configuration definition and a very easy way of installation.
Let’s see an example.
With this lines of code you will download Visithor, ready to be used.
1 2 3 4
You can download it as a global executable
1 2 3 4 5
Creating your configuration
As easy as it seems. This is a random configuration file with a random set of
urls. If your
visithor.yml file is placed in the same folder than you are,
then you don’t have to specify its location. Otherwise, please use the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
In this case, the execution result is 0
Once you have it installed and you have a configuration file, let’s see what happens!
1 2 3 4 5 6 7 8 9 10 11 12 13
As you can see, we have an error. We expect a
200 code when we call
http://nonexistingurl.com but the real response is
404, so it fails. Then,
the execution result is 1.
You can integrate Visithor with your Symfony projects right now. I expect some other integrations will be available soon.
If you use this bundle, then you will be able to define your routes not with the final path but with the route name and a bunch of parameters, as it is shown here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
This project is being so useful for me, I expect it will be for you as well :)
Of course, you can add Visithor in your travis tests suite. You can use the [—format|-f] option to change the format and use dots
1 2 3 4