From 7fd2178aeb976d9efa7ac913743c6dd72ed19ed6 Mon Sep 17 00:00:00 2001 From: Mark Ragazzo Date: Wed, 10 Dec 2014 22:44:27 +0400 Subject: [PATCH 1/3] added code coverage ti yii2_basic --- apps/basic/tests/README.md | 48 ++++++++++++++++++++++++++++++++ apps/basic/tests/codeception.yml | 20 +++++++++++++ 2 files changed, 68 insertions(+) diff --git a/apps/basic/tests/README.md b/apps/basic/tests/README.md index f14db26a51..b5c0141760 100644 --- a/apps/basic/tests/README.md +++ b/apps/basic/tests/README.md @@ -59,5 +59,53 @@ codecept run functional codecept run unit ``` +Code coverage support +--------------------- + +By default, code coverage is disabled in `codeception.yaml` configuration file, you should uncomment needed rows to be able +to collect code coverage. You can run your tests and collect coverage with the following command: + +``` +#collect coverage for all tests +codecept run --coverage-html --coverage-xml + +#collect coverage only for unit tests +codecept run unit --coverage-html --coverage-xml + +#collect coverage for unit and functional tests +codecept run functional,unit --coverage-html --coverage-xml +``` + +You can see code coverage output under the `tests/_output` directory. + +###Remote code coverage + +When you run your tests not in the same process where code coverage is collected, then you should uncomment `remote` option and its +related options, to be able to collect code coverage correctly. To setup remote code coverage you should follow [instructions](http://codeception.com/docs/11-Codecoverage) +from codeception site. + +1. install Codeception c3 remote support `composer require "codeception/c3:*"`; + +2. copy c3.php file under your `web` directory and include; + +3. include `c3.php` file in your `index-test.php` file before application run, so it can catch needed requests. + +Configuration options that are used by remote code coverage: + +- c3_url: url pointing to entry script that includes `c3.php` file, so `Codeception` will be able to produce code coverage; +- remote: whether to enable remote code coverage or not; +- remote_config: path to the `codeception.yaml` configuration file, from the directory where `c3.php` file is located. This is needed + so that `Codeception` can create itself instance and collect code coverage correctly. + +By default `c3_url` and `remote_config` setup correctly, you only need to copy and include `c3.php` file in your `index-test.php` + +After that you should be able to collect code coverage from tests that run through `PhpBrowser` or `WebDriver` with same command +as for other tests: + +``` +#collect coverage from remote +codecept run acceptance --coverage-html --coverage-xml +``` + Please refer to [Codeception tutorial](http://codeception.com/docs/01-Introduction) for more details about writing and running acceptance, functional and unit tests. diff --git a/apps/basic/tests/codeception.yml b/apps/basic/tests/codeception.yml index 0a45a0c087..b71ba31c1e 100644 --- a/apps/basic/tests/codeception.yml +++ b/apps/basic/tests/codeception.yml @@ -1,4 +1,24 @@ actor: Tester +#coverage: +# #c3_url: http://localhost:8080/index-test.php/ +# enabled: true +# #remote: true +# #remote_config: '../tests/codeception.yml' +# white_list: +# include: +# - ../models/* +# - ../controllers/* +# - ../commands/* +# - ../mail/* +# blacklist: +# include: +# - ../assets/* +# - ../config/* +# - ../runtime/* +# - ../vendor/* +# - ../views/* +# - ../web/* +# - ../tests/* paths: tests: codeception log: codeception/_output From c51f0452345b77485515f65f9e03f5dce31637bc Mon Sep 17 00:00:00 2001 From: Mark Ragazzo Date: Wed, 10 Dec 2014 22:46:53 +0400 Subject: [PATCH 2/3] doc fix --- apps/basic/tests/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/basic/tests/README.md b/apps/basic/tests/README.md index b5c0141760..3041b5f425 100644 --- a/apps/basic/tests/README.md +++ b/apps/basic/tests/README.md @@ -84,9 +84,9 @@ When you run your tests not in the same process where code coverage is collected related options, to be able to collect code coverage correctly. To setup remote code coverage you should follow [instructions](http://codeception.com/docs/11-Codecoverage) from codeception site. -1. install Codeception c3 remote support `composer require "codeception/c3:*"`; +1. install `Codeception c3` remote support `composer require "codeception/c3:*"`; -2. copy c3.php file under your `web` directory and include; +2. copy `c3.php` file under your `web` directory; 3. include `c3.php` file in your `index-test.php` file before application run, so it can catch needed requests. From 97398dac80e50b0f02762f1f0eb2510aa0de1f42 Mon Sep 17 00:00:00 2001 From: Mark Ragazzo Date: Wed, 10 Dec 2014 23:01:08 +0400 Subject: [PATCH 3/3] fixed docs --- apps/basic/tests/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/basic/tests/README.md b/apps/basic/tests/README.md index 3041b5f425..8134fb3a7a 100644 --- a/apps/basic/tests/README.md +++ b/apps/basic/tests/README.md @@ -62,7 +62,7 @@ codecept run unit Code coverage support --------------------- -By default, code coverage is disabled in `codeception.yaml` configuration file, you should uncomment needed rows to be able +By default, code coverage is disabled in `codeception.yml` configuration file, you should uncomment needed rows to be able to collect code coverage. You can run your tests and collect coverage with the following command: ``` @@ -94,7 +94,7 @@ Configuration options that are used by remote code coverage: - c3_url: url pointing to entry script that includes `c3.php` file, so `Codeception` will be able to produce code coverage; - remote: whether to enable remote code coverage or not; -- remote_config: path to the `codeception.yaml` configuration file, from the directory where `c3.php` file is located. This is needed +- remote_config: path to the `codeception.yml` configuration file, from the directory where `c3.php` file is located. This is needed so that `Codeception` can create itself instance and collect code coverage correctly. By default `c3_url` and `remote_config` setup correctly, you only need to copy and include `c3.php` file in your `index-test.php`