i am trying to run tests:
/var/www/yii2/apps/basic/tests$ codecept run ./functional/LoginCept.php
result:
[CodeceptionExceptionConfiguration]
Configuration file is invalid
run with config option:
/var/www/yii2/apps/basic/tests$ codecept run ./functional/LoginCept.php --config ./functional.suite.dist.yml
result:
[CodeceptionExceptionConfiguration]
Log path is not defined by key "paths: log"
you should execute tests from the root dir and not the tests dir. With config option you should specify path to codeception.yml file (global config) and not the suite config.
So just run it from app dir and everything will go smoothly )
/var/www/yii2/apps/basic$ codecept run tests/functional/LoginCept.php
Thanks a lot
@ostapetc please close the issue if the problem is solved. Thanks.
now i have error:
os@os-GE70-0NC-0ND:/var/www/yii2/apps/basic$ codecept run tests/functional/LoginCept.php
Codeception PHP Testing Framework v1.7.1
Powered by PHPUnit 3.7.27 by Sebastian Bergmann.
PHP Fatal error: Call to undefined method CodeceptionScenario::condition() in /var/www/yii2/apps/basic/tests/functional/TestGuy.php on line 345
@ostapetc You need to run codecep build before run
tried to run tests on freshly installed basic app. All acceptance tests passed, but all functional tests failed with errors like:
1) Failed to ensure that about works in AboutCept.php
Sorry, I couldn't am on page "?r=site/about":
yii\base\InvalidConfigException: Object configuration must be an array containing a "class" element.
Scenario Steps:
1. I am on page "?r=site/about"
After i changed "web/index-test.php" to "config/web-test.php" in functional.suite.dist.yml i got next error:
Functional Tests (4) -------------------------------------------
Trying to ensure that about works (AboutCept.php) Error
PHP Fatal error: Class 'Yii' not found in phar:///var/www/codecept.phar/src/Codeception/Module/Yii2.php on line 70
FATAL ERROR. TESTS NOT FINISHED.
Class 'Yii' not found
in phar:///var/www/codecept.phar/src/Codeception/Module/Yii2.php:70
And i don't know how to fix that :-(
I thought class Yii is handled by composer's autoloader. Or not?
Not sure what happens, but Yii autoloading mechanism is not started.
Pretty strange
may be I'm running tests wrong way:
1) i downloaded codecept.phar in my project's parent directory
2) in project directory i run "php ../codecept.phar build"
3) in same dir run "php ../codecept.phar run"
This is correct?
Can you create a repo on github and point a link to it?
That would be the most simple way to get into the same boat. As well this way I could easily reproduce your issue
i did noting specific. Following steps to reproduce on ubuntu 13.10 (apache docroot is pointed to /var/www/yii2-test/web):
cd /var/www
curl -s http://getcomposer.org/installer | php
wget http://codeception.com/codecept.phar
php composer.phar create-project --stability=dev yiisoft/yii2-app-basic yii2-test
cd yii2-test
php ../codecept.phar build
php ../codecept.phar run
at this point acceptance tests are passing, functional failing with errors:
1) Failed to ensure that about works in AboutCept.php
Sorry, I couldn't am on page "?r=site/about":
yii\base\InvalidConfigException: Object configuration must be an array containing a "class" element.
Scenario Steps:
1. I am on page "?r=site/about"
if i change entryScript in tests/functional.suite.dist.yml from "web/index-test.php" to "config/web-test.php" i see
Functional Tests (4) -------------------------------------------
Trying to ensure that about works (AboutCept.php) Error
PHP Fatal error: Class 'Yii' not found in phar:///var/www/codecept.phar/src/Codeception/Module/Yii2.php on line 70
FATAL ERROR. TESTS NOT FINISHED.
Class 'Yii' not found
in phar:///var/www/codecept.phar/src/Codeception/Module/Yii2.php:70
@pavimus , @DavertMik
functional test are not working because Codeception's Yii2 Connector expects that entryScript will return an array with configuration for Yii Application class initialisation
I have mentioned it here couple of days ago
https://github.com/yiisoft/yii2/issues/45#issuecomment-27763415
but in any case functional test are not working properly now
As for Unit test - I was able ti run them only after including autoloading script in unit/_bootstrap.php
require(__DIR__ . '/../../vendor/autoload.php');
without it Yii class was not found
Fixed.
Not sure if this is the right place to put it, but I am still having trouble running functional tests on a fresh install. Acceptance tests run fine, but functional tests do not.
This is my command log:
composer create-project --stability=dev yiisoft/yii2-app-basic yii-basic-test
cd yii-basic-test/
<copy/modify *.yml config files>
codecept build
codecept run
This is 1 of the 8 errors (8 functional tests):
1) Failed to ensure that about works in AboutCept.php
Sorry, I couldn't am on page "?r=site/about":
yii\base\InvalidParamException: The HTTP status code is invalid:
Scenario Steps:
1. I am on page "?r=site/about"
#1 D:\programs\xampp\htdocs\yii-basic-test\vendor\yiisoft\yii2\yii\base\Component.php:453
#2 D:\programs\xampp\htdocs\yii-basic-test\vendor\yiisoft\yii2\yii\web\Response.php:283
#3 D:\programs\xampp\htdocs\yii-basic-test\tests\functional\TestGuy.php:510
#4 D:\programs\xampp\htdocs\yii-basic-test\tests\functional\AboutCept.php:4
These are my config files:
class_name: WebGuy
modules:
enabled:
- PhpBrowser
- WebHelper
config:
PhpBrowser:
url: 'http://localhost/yii-basic-test/web/index-test.php'
class_name: TestGuy
modules:
enabled: [Filesystem, TestHelper, Yii2]
config:
Yii2:
entryScript: 'web/index-test.php'
url: 'http://localhost/yii-basic-test/'
@amnah I think it is related to https://github.com/yiisoft/yii2/commit/f5219d24816c8b55aa757d37b7215905f3ee7073#commitcomment-4661711
so just wait while it will be updated in codeception yii2 connector
Should be working fine now if you update yii2
@qiangxue I have sent a PR to codeception this morning to fix this. We should remove the null check from Response when it is merged and released.
Cool! I wanted to do the same. I'm not happy with my temp fix in setStatusCode. Thanks.
Report and converstation is a bit hidden. Was in this commit: https://github.com/yiisoft/yii2/commit/f5219d24816c8b55aa757d37b7215905f3ee7073#commitcomment-4661711
Please anyone give good guide for codeception tests for yii2 ..
Its so hard to find resources to codeception tests.............
**Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"firefox"}}
couldn't connect to host
Please make sure that Selenium Server or PhantomJS is running.**
_This is an automated comment, triggered by adding the label question._
Please note, that the GitHub Issue Tracker is for bug reports and feature requests only.
We are happy to help you on the support forum, on IRC (#yii on freenode), or Gitter.
Please use one of the above mentioned resources to discuss the problem.
If the result of the discussion turns out that there really is a bug in the framework, feel free to
come back and provide information on how to reproduce the issue. This issue will be closed for now.