📜 ⬆️ ⬇️

Codeception - project news

image I already wrote on Habré about Codeception - a framework for testing applications for PHP. If you have never written tests for your application before, you should definitely take a look at Codeception. It is very easy to use and made specifically to protect developers from the routine.

Today I would like to tell you what features have appeared in the project recently, and I will also answer a couple of popular questions.

Installation via Composer

Now you no longer need PEAR to install. With him often there are many different problems that require a tambourine and shaman songs. If you are a modern person and have forgotten all the ritual songs of the ancient ancestors, try Composer. With it, you can easily set Codeception itself, as well as all the necessary libraries, including Mink and PHPUnit.

Instructions here .
')
Framework support

Now you can write functional tests for the following frameworks: Symfony2, Zend Framework, symfony, Kohana, SocialEngine . The last two modules, by the way, are made by third-party developers, for which a special thank you to them. Their example shows that to make a module for your favorite framework is not so difficult.

Documentation generation

Many say tests are the best documentation. But not always tests are written with the expectation of reading. In Codeception, everything is different, in the Cest tests you describe your actions and the desired result.

$I->testMethod('\Service\Group::create'); $I->wantTo('create a group'); $I->executeTestedMethodWith('DemoGroup', 1) ->seeInRepository('Model\Group', array('name' => 'DemoGroup', 'user_id' => 1, 'type' => 'group')) ->seeResultIs('int'); 


If you use the phpDocumentor2 documentation generation system (formerly DocBlox), then using the built-in Codeception plug-in, this test will be added to the method description. It will be converted to text and will look like this:

With this method I can create group

If I execute \ Service \ Group :: create ("DemoGroup", 1)
I will see in repository “Model \ Group”, {“name”: “DemoGroup”, “user_id”: 1, “type”: “group”}
I will see result is “int”

Now the documentation will contain information about how a particular method behaves, depending on the parameters. How to connect the plugin - read here .

Basic support for CI systems

Now Codeception can be connected to Continuous Integration servers, such as Jenkins and Bamboo. Unfortunately, we managed to test the integration so far only with Bamboo. But the result is written in XML and in theory should be easily picked up by other CI systems. If there are problems with them - let us know, we’ll correct everything promptly.

All this, as well as many other goodies are available in the latest version of Codeception 1.0.8 .
Install , use.

And now the answers to popular questions:

Why Codeception if there is PHPUnit?

I’ll tell you a secret: odeception is not a bike, but an add-on for PHPUnit. It allows you to perform script tests on the PHPUnit engine. In this case, all your existing tests for PHPUnit Codeception can catch without any problems. You can easily add functional and acceptance tests to them. Very many tasks requiring crutches (for example, integration with Selenium, from the database) in Codeception have already been solved.

Why Codeception, if there is Selenium?

Codeception can perform tests for Selenium. But tests in Codeception are easier to maintain, they are more flexible. For example, you can perform some of the tests not in the browser, but through its Goutte emulator. Or do not use the web server for testing at all, but directly access the application. This will significantly reduce the execution time of your tests. In addition, Codeception assumes all the problems associated with data cleaning between tests.

Why Codeception if there is a behat?

The question is: why Linux, if you have Windows. The availability of alternatives is always good. At a minimum, a system that allows writing acceptance tests for PHP will not be superfluous in the ecosystem.

Future plans

In the near future, code coverage will be added and the number of supported frameworks will increase. But offer your ideas. What would you like to see in Codeception?

Source: https://habr.com/ru/post/143567/


All Articles