Tada! Mink 0.1 is here.
But what is Mink? Mink is a browser emulators abstraction layer. It defines basic API through which you can talk with specific browser emulator libraries.
Mink drivers define bridge between Mink and those libraries. For now, Mink supports 2 drivers:
- GoutteDriver – Symfony2 BrowserKit+DomCrawler libraries bridge. It covers basic headless browser testing needs and integrates flawlessly with any web application out there, including Symfony2, symfony1, Drupal, WordPress and others.
- SahiDriver – Sahi framework bridge. This one gives you ability to actually run your tests inside real browsers (Firefox, Chrome, IE, Safari). Think about Sahi as a “much easier Selenium”.
pear install behat/mink
Mink was created specifically for the Behat BDD framework. To give everyone ability to test their complex web applications with Behat.
To integrate Mink into your Behat test suite, you need to do 2 simple steps:
behat.ymlto actually include Behat:
default: environment: parameters: start_url: http://your_app_host.loc/
Require Mink and PHPUnit autoloaders inside the
Now, you’re able to use Mink steps inside your Behat features. Check all available steps with:
Or you can specify the steps in your native language. Yes, yes – Mink has step translations for some languages (russian and french by now):
behat –steps –lang fr
By default, all Mink steps will use
GoutteDriver. It means that all your steps will be executed very fast in a headless browser emulator, written by Fabien Potencier.
But what if you want to actually run/test your features inside a real browser?
SahiDriver comes to the rescue!
SahiDriver are nicely configured out-of-the box in Mink’s
behat.yml. So, to switch some of your scenarios to in-browser tester – simply tag them with
Scenario: User can login
Of course, until you install and start the Sahi proxy, you’ll get a Sahi exception saying that the “Sahi proxy is not started”. To install Sahi, do the following:
- Go to http://sourceforge.net/projects/sahi/files/sahi-v35/ and download the
- Unzip the archive into any folder (for example your home root)
/your/sahi/path/userdata/bin/start_sahi.shfor Linux and MacOS OR
yoursahipathuserdatabinstart_sahi.batfor Windows. This will start Sahi proxy server.
Now, before any your test suite, you need to start proxy (step 3) and you’re done. Mink and Sahi will automatically start the proper browser, when needed
By default, Mink will use
firefox as the browser to test with Sahi. Of course, Sahi supports different browsers on different OS’s (firefox, ie, safari, etc.).
Information about configuring and using different browsers is avaialble in the Sahi documentation.
Changing Mink’s browser is as simple as:
Known limitations and bugs
For now, Sahi has some limitations/bugs on Linux systems. For example, the Sahi proxy doesn’t close browser after a test in Linux. Fortunately, Narayan (Sahi developer) is very fast with fixes, and i’m sure we will have a fix for the bug as fast as possible. So, feel free to tell him “thanks” on twitter (@narayanraman) for his great work. Mink wouldn’t be possible without his insane project!
Mink in Behat
Mink in other testing tools
Mink was created especially for Behat project. But that doesn’t mean that you can’t use Mink with other testing tools:
Release and documentation
Mink 0.1 is already released and available to everyone from pear.behat.org.
The repository is at Behat GitHub organisation.
Full documentation with use cases will be available tommorow at docs.behat.org.