我目前有两个功能测试:
用户登录测试
$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');
Admin login test
$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
成功运行测试
这是我的错误还是codeception的错误?我试过启用过滤器,但没有成功。我似乎也无法将环境设置为local
而不是testing
。
有同样的问题!终于想通了。这似乎是Codeception v2.0.3中的一个bug
在您的编写器中。Json,现在将版本设置为2.0.2(直到在未来的版本中修复)
"codeception/codeception": "2.0.2"
然后运行composer update以反映更改:
php composer.phar update
所有的测试在一起运行时应该都能正常工作。希望它对你有用!