If you liked what you've learned so far, dive in!
Subscribe to get access to this tutorial plus
video, code and script downloads.
I hope you’re really excited to start using Behat and Mink in your project, we love to use it in ours.
Behat is typically used to test websites, but it can also be used very well to test against your API’s. If you want more details, see the WebApiContext class, which holds a lot of step definitions for testing your API.
One common question is: “Can I use Behat and Mink on my continuous integration server?”. The answer is absolutely yes! In the last chapter, we talked about the junit format, which you can use to hook into your CI system. Beside this, there are a number of things you’ll need to think about.
Tip
We now have even more information on continuous integration, specifically with Travis CI: How to use Behat and Selenium on Travis CI
First, you’ll need a real database to be setup and configured for your application.
Second, your application needs to be web accessible on your CI server. Remember that Mink operates by making real HTTP requests, so your application needs to be configured with your web server so that you can at least make local requests to real URLs.
Finally, if you’re using Selenium you’ll need to have the Selenium server running and a utility called xvfb running. On a server, you don’t really have a GUI, which means that you can’t really open a browser. With xvfb, which stands for X virtual frame buffer, you can run a browser as if you were on any computer. The exact setup will vary, but remember to start xvfb and export your display:
sh -e /etc/init.d/xvfb start
export DISPLAY=:99.0
Ok, start testing! And we’ll see you next time!
"Houston: no signs of life"
Start the conversation!
// composer.json
{
"require": {
"symfony/symfony": "^2.7", // v2.7.4
"twig/twig": "^1.22", // v1.22.1
"sensio/framework-extra-bundle": "^3.0", // v3.0.10
"doctrine/doctrine-bundle": "^1.5", // v1.5.1
"doctrine/orm": "^2.5" // v2.5.1
},
"require-dev": {
"behat/mink-extension": "^2.0", // v2.0.1
"behat/mink-goutte-driver": "^1.1", // v1.1.0
"behat/mink-selenium2-driver": "^1.2", // v1.2.0
"phpunit/phpunit": "^4.8" // 4.8.7
}
}