FREELessons: 13Length: 1.3 hours

Next lesson playing in 5 seconds

  • Overview
  • Transcript

3.2 Codeception

In this lesson we’ll take a look at the Codeception testing framework. We’ll explore its features and basic installation instructions so that we can work with it in the next section.

Related Links

3.2 Codeception

In the last video, we installed PHP Unit, which we'll use in the next section to write unit tests. In this lesson, we'll learn about another testing framework called Codeception, which we'll use for writing functional tests. Now, don't worry if you don't know what these types of tests are or what they mean. We'll learn all about them in the next section of the course. So, let's begin learning about and installing the Codeception testing framework. I'm going to switch in to my browser, and here is the Codeception website. You can visit this at Codeception dot com. So, Codeception is an easy to use testing framework. It offers a variety of different ways to test your PHP applications. It's super easy to use and requires just a little bit of configuration. You can do acceptance testing, functional testing, and unit testing all with just Codeception. Now, we'll learn more about actually using Codeception in the next section. But you could go ahead and look around at the documentation if you want a little more information. But for now, let's just go ahead and install it. So, I find using Composer to be the easiest way to install Codeception. All you have to do is within your web application's composer dot jason file, add in a line to include it. So, let's switch into our text editor. Here's my PHP Testing Basics folder that I've been using. And i'll just open up my composer dot Jason file. And right after the PHP unit statement here, make sure to put a comma. And I'm just going to paste it in, to save a little bit of time. As you can see here, we're including the Codeception framework. Make sure to save your composer file. We can now close it out. And now let's switch into the terminal. And let's install Codeception and all of its dependencies. I'm first going to change into my sites directory and then into PHP testing basics. And let's run composer update. That'll only take a few minutes to download Codeception and any other dependencies that it might need. There we go. The download is complete. Now, we just need to boot strap it to our application. Let's run one more command. We use a dot, and a forward slash, vendor slash bin, slash code set, space, boot strap. There we go. And that should install Codeception for your application. Of course, here you can see that my project was already initialized, and that's because I've done it ahead of time. But on yours, it's going to initialize that for you. Now, we just want to make sure that our installation was successful. To do that, we can run the following command; PHP, vendor slash bin, slash code set, there we go. If you see this list of options, like I have on my screen for the code set command, then you're all set. Codeception is now installed and ready for use. Let's now move on and examine one last PHP Testing Framework called Behat. I'll see you there.

Back to the top