对于集成测试,我将它们添加到Travis上,但很多测试都失败了!
因此,我在.travis.yml
上添加了此命令:cat tests/_output/*
结果解释了为什么测试失败。以下是travis环境页面的输出:
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
[THE FORM]
</body>
</html>
如您所见,我的基本模板未加载到travis环境中。
以下是本地生成的同一登录页面的截断部分:
<html lang="en">
<head>
<meta charset="UTF-8" />
<link href="/css/f5f986f_app_1.css" type="text/css" rel="stylesheet" media="screen" />
<link href="/css/f5f986f_bootstrap.min_2.css" type="text/css" rel="stylesheet" media="screen" />
<link href="/css/f5f986f_bootstrap-theme.min_3.css" type="text/css" rel="stylesheet" media="screen" />
<link href="/css/f5f986f_font-awesome.min_4.css" type="text/css" rel="stylesheet" media="screen" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="/js/52ec12c_jquery.min_1.js"></script>
<title>G-Equip • Log in</title>
<link rel="shortcut icon" href="/favicon.ico" /> </head>
<body>
[....]
[THE FORM]
[....]
</body>
</html>
这是我的测试:
class AuthCest
{
public function _before(FunctionalTester $I)
{
$I->amOnPage('/login');
//Menu verification
$I->seeInTitle('Log in');
}
}
因此,在本地,页面已经很好地加载了它的模板。但是在特拉维斯,我没有完整的模板,我没有标题标签!因此,此测试失败了:$I->seeInTitle('Log in')
Codeception抛出此失败:
找不到
<title>
的失败标记元素。
为什么travis环境的观点不同?
以下是我的.travis.yml文件的简化版本:
# Project language
language: php
# Allows use container-based infrastructure
sudo: false
# Start mysql service
services:
- mysql
# Cache composer packages so "composer install" is faster
cache:
directories:
- $HOME/.composer/cache/files
php:
# aliased to a recent 7.1.x version
- 7.1
# Define an environment variable
env:
- SYMFONY_VERSION="3.3.*" DB=mysql
# Update composer
before-install:
- composer self-update
before_script:
- cp app/config/parameters.yml.travis app/config/parameters.yml
- composer install
- mysql -e 'create database symfony;'
- php bin/console doctrine:migrations:migrate --no-interaction
# loading data for phpunit and codeconcept tests
- php bin/console doctrine:fixtures:load --fixtures ./src/AppBundle/DataFixtures -n --env=test
script:
# Server must be started for codeconcept tests.
- php bin/console server:start
- php vendor/bin/codecept run
- php bin/console server:stop
- cat tests/_output/*
有些东西肯定是错误配置的,你有什么想法吗?