A
A
Alexey Volegov2015-05-20 18:50:59
Yii
Alexey Volegov, 2015-05-20 18:50:59

How to make friends Yii2 and Codeception with coverage?

Good afternoon. There was a need to cover your REST API with tests, and at the same time see the code coverage with these tests. I kind of figured out how to write a simple test with a REST call, but --coverage-htmlit doesn’t work out with stubbornness!
I'm using Yii2-basic as a base, installed all required dependencies. I have Codecept globally from composer (installed in include_path).
It is not clear to me how c3.php works and how to connect it to the project so that it starts working adequately.
Here are my configs:
tests/codeception.yml

actor: Tester
paths:
    tests: codeception
    log: codeception/_output
    data: codeception/_data
    helpers: codeception/_support
settings:
    bootstrap: _bootstrap.php
    suite_class: \PHPUnit_Framework_TestSuite
    memory_limit: 1024M
    log: true
    colors: true
config:
    test_entry_url: 'http://site.local/index-test.php'

acceptance.suite.yml
class_name: AcceptanceTester
modules:
    enabled:
        - PhpBrowser
        - REST
    config:
        PhpBrowser:
            url: http://site.local

coverage:
  enabled: true
  remote: true
  c3_url: 'http://site.local/index-test.php'

I leave tests from acceptance as they are.
web/c3.php
// include composer vendor
include 'vendor/autoload.php';

$_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'] = 1;
$_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'] = '/../tests/codeception.yml';

I don't connect to index-test.php from 3.php....
nginx settings
location /c3/ {
    try_files /c3.php?$args /c3.php;
  }

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

As a result, my tests are running, but the report in html is empty. Maybe I'm doing something fundamentally wrong???

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question