Unlimited WordPress themes, graphics, videos & courses! Unlimited asset downloads! From $16.50/m
Lessons:13Length:1.3 hours
Crs 107001
  • Overview
  • Transcript

3.3 Behat

In this lesson we’ll take a look at the Behat testing framework. The Behat testing framework uses stories to describe how your application should behave. We’ll explore its features and basic installation instructions so that we can work with it in the next section.

Related Links

3.3 Behat

In the last couple of lessons, we installed the PHP unit framework to use for unit testing. The Codeception framework to use for functional testing. And now in this lesson, we'll take a look at and install one last testing framework, Behat, which we'll use for acceptance testing. Again, don't worry if you don't know what these types of tests are or what they mean just yet. We'll learn all about them in the next section of the course. So let's take a look at, and install the Behat testing framework. I'll switch in to my browser. Here we go, you can visit the website at Behat.org. So the Behat PHP testing framework follows the BDD methodology that we looked at earlier in the course. This framework strives to make your tests appear as stories rather than code. By writing features and scenarios which describe how your application should behave. It's really easy to get started with, and it does have excellent documentation. So feel free to poke around. But when you're ready, let's go ahead and install Behat. Again, I prefer to use Composer to install Behat, just like with the other frameworks. All you need to do is include it in your composer.json file. So I'm just going to switch into my text editor. And within our phptestingbasics folder, I'll open up my composer.json file. And right after the codeception statement here, make sure to put a comma. And I'm just going to paste mine in here to include the Behat testing framework. And this simply requires Behat and any of its dependencies as a dependency for our application. Now, let's run Composer to install it. I'll switch into my terminal. Let me change directories into my phptestingbasics folder. And let's run composer update. This will just take a few minutes to download Behat and any other dependencies that it may need. There we go, Behat is installed. Now lastly, let's verify that our installation was successful by running the following command, php vendor/bin/behat -h. And if the following options show up for the Behat command, like seen here on my screen, then Behat is installed. And you're now ready to proceed to the next section of the course where we'll put all three of the PHP testing frameworks that we've downloaded into use. I'll see you there.

Back to the top