我目前有两个功能测试:
用户登录测试
$I = new FunctionalTester($scenario);
$I->am('wedding guest');
$I->wantTo('Sign in to the website and see the home page');
$I->logIn('user@mysite.nl', 'secret');
$I->seeCurrentUrlEquals('');
$I->see('user page string');
管理员登录测试
$I = new FunctionalTester($scenario);
$I->am('The website admin');
$I->wantTo('Sign in to the website and see the admin page');
$I->login('admin@mysite.nl', 'mypass');
$I->seeCurrentUrlEquals('/admin');
登录方法的代码如下:
public function login($email, $password){
$I = $this->getModule('Laravel4');
$I->amOnPage('login');
$I->fillField("email", $email);
$I->fillField("password", $password);
$I->click("Log in!");
}
当我单独运行每个测试时,它们会成功,但是当我运行整个功能套件时(只有这两个测试是套件的一部分),我收到以下错误:
vendor/bin/codecept run functional
...
Functional Tests (2) ------------------------------------------------------------------------------------------------------------
Trying to Sign in to the website and see the admin page (SignInWebsiteAdminCept) Ok
...
1) Failed to sign in to the website and see the home page in
SignInUserCept (/var/www/tests/functional/SignInUserCept.php)
Couldn't login "user@mysite.nl","secret":
Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
...
#1 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1049
#2 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1017
#3 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:996
#4 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:776
#5 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:746
#6 /var/www/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php:81
#7 /var/www/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php:332
#8 /var/www/tests/_support/FunctionalHelper.php:15
#9 /var/www/tests/functional/FunctionalTester.php:369
#10 /var/www/tests/functional/SignInWeddingGuestCept.php:7
它似乎无法找到路线,但它显然存在,因为我能够通过执行$ vendor/bin/codecept run functional SignInUserCept.php
成功运行测试
这是我的错误还是代码中的错误?我试过启用过滤器,没有运气。我似乎也无法将环境设置为local
而不是testing
。
答案 0 :(得分:3)
有同样的问题!终于想通了。它似乎是Codeception v2.0.3中的一个错误
在您的composer.json中,暂时将版本设置为2.0.2(直到在将来的版本中修复)
"codeception/codeception": "2.0.2"
然后运行composer update以反映更改:
php composer.phar update
所有测试现在应该在一起运行时起作用。希望它适合你!