Recently, I used the Codeception inside PIMCore
in one of my project. And i found that it's very easy to implement and
helpful for the code-coverage report. Before that i also used the
PHPUnit tool for the Unit testing and code-coverage analysis.
Yes, Codeception is build on top of the PHPUnit and it makes some handy work to implement it.
I used the codeception inside the PIMCore, PIMCore is a tool for the CMS, CRM, E-Commerce development.
Although, PIMCore is built on Zend framework, So you can use the below steps to enable the codeception there.
Please follow the steps to enable and run the codeception inside PIMCore. Step 1: Install the codeception through the composer like below
# composer require "codeception/codeception"
Step 2: Check codeception is working or not, run the below command
# php vendor/codeception/codeception/codecept
Step 3: Install the codeception tests dir into your application
Step 5: Write up the test case assertions for all the functional logics.
class DummyTest extends \Codeception\Test\Unit
{
protected function _before()
{
}
protected function _after()
{
}
// tests
public function testDataBridge()
{
}
}
Step 6: Run the codeception with the below command:
# php vendor/codeception/codeception/codecept run
It will run the written functional unit cases and give you a report either no of pass or fail assertions.
Step 7. Install the xdebug module to get the code coverage report
# apt-get install
# /etc/init.d/apache2 restart
Enable the xdebug module
# phpenmod xdebug
# /etc/init.d/apache2 restart
Install the c3 module to get the code-coverage report
# composer require "codeception/c3"
Include c3.php in your index.php like
include "c3.php"
Step 8: Now you are ready to get the code-coverage report
Edit you codeception.yml file and add the below line to enable the coverage
coverage:enabled:true
For your further setting please have a look the below url
http://codeception.com/docs/11-Codecoverage
# php vendor/codeception/codeception/codecept run --coverage --coverage-html
It will give you a code-coverage report with html format.
No comments:
Post a Comment