web-tp3 / cag_tests
Connecta AG :: 基本测试和示例
Requires
- mikey179/vfsstream: ~1.6.0
- typo3/class-alias-loader: ^1
- typo3/cms-core: ^8.7 || ^9.5 || ^10.4 || ^11
- typo3fluid/fluid: ^2
Requires (Dev)
Suggests
- codeception/codeception: ^2.4
- typo3/cms-styleguide: ^8 || ^9.0 || ^10
README
这是 CAG 测试,允许您为 Typo3 安装执行标准单元、验收和功能测试。cag_tests 集成。
功能特性
以下测试由扩展执行
- 测试来自 typo3 核心的开发版本
- 扩展测试以支持自定义扩展
git clone git@bitbucket.org:web-tp3/cag_tests.git
cd cag_tests/
rm -rf .git .gitignore
composer install
git init
2 资源
资源/核心 => 核心测试
资源/扩展 => 扩展测试 + 自定义验收测试模板(BackendLoginPrototype.php)
集成 cag_tests 扩展
在 composer.json 中需要以下包,并且可能还需要在服务器端安装和激活
"require": {
"typo3/cms": "dev-TYPO3_8-7",
"helhum/typo3-console": "^5",
"helhum/dotenv-connector": "^2",
"helhum/config-loader": "*",
"georgringer/news":"*"
}
"require-dev": {
"devlog/devlog": "dev-master",
"deployer/deployer": "^6",
"consolidation/robo": "^1",
"phpunit/phpunit": "*",
"codeception/codeception":"*",
"typo3/testing-framework": "8.x-dev",
"friendsofphp/php-cs-fixer": "^2.13@dev",
"se/selenium-server-standalone":"~2.53",
"typo3/cms-styleguide" :"~8.0.8",
"ext-soap": "*",
"phpunit/php-invoker":"^1.1",
"nimut/testing-framework": "^3.0@dev"
}
计划在开发环境中进行测试 -> require-dev web-tp3/cag_tests
测试扩展 下载。
系统上应已安装 https://getcomposer.org.cn/,有关安装详情,请参阅其文档。对于功能测试,应准备数据库连接和凭据。
包含的功能
cag_tests 框架包装器
- 1000 个单元测试
- 50 个功能测试
- 25 个验收测试
包含两个基本功能:资源/核心 & 资源/扩展测试。启动配置在 Build 文件夹中,例如 FunctionalHelhumTests.xml,以及预配置的标准参数 "Fixtures"。
其他测试,如
PHPUnit 测试
TYPO3 >=8.7
php bin/phpunit --configuration web/typo3conf/ext/cag_tests/Resources/Core/Build/UnitTests.xml --log-junit UnitExtTests.log
对于过时的单元测试
php bin/phpunit --configuration web/typo3conf/ext/cag_tests/Resources/Core/Build/UnitTestsDeprecated.xml --log-junit DeprecatedTests.log
功能测试
(phpunit & testing-framework)
单元测试和功能测试之间的区别
自从 TYPO3 6.2 以来,除了单元测试,您还可以为 TYPO3 编写功能测试。
单元测试应该只测试一小段代码,不应修改环境(文件、数据库)。然而,通过功能测试,您可以测试完整的功能。
从 TYPO3 CMS 版本 6.2 开始,功能测试的执行及其所需设置得到了简化。有关更多详细信息,请参阅 Blueprints/StandaloneUnitTests。
https://wiki.typo3.org/Functional_testing
shell 脚本
执行所有功能测试
TYPO3 >=8.7
php bin/phpunit --configuration ../web/typo3conf/ext/cag_tests/Resources/Core/Build/FunctionalTests.xml --log-junit FunctionalTests.log
php bin/phpunit --configuration ../web/typo3conf/ext/cag_tests/Resources/Ext/Build/FunctionalTests.xml --log-junit FunctionalExtTests.log
验收测试
(codeception & chromedriver)
https://docs.typo3.org/typo3cms/CoreApiReference/Testing/Index.html
从 TYPO3 v8 开始的验收测试
从 TYPO3 v8 的早期版本开始,核心就带有基于 Codeception 的验收测试,这些测试使用 chromedriver 作为无头 Chrome 浏览器执行。
获取 TYPO3 源代码和已安装的 composer 依赖项,并启动 chromedriver 和 PHP HTTP 服务器
mkdir -p web/typo3temp/var/tests
./bin/chromedriver --url-base=/wd/hub > /dev/null 2>&1 &
php -S 0.0.0.0:8000 >/devclass_name: AcceptanceTester /null 2>&1 &
sleep 3;
typo3DatabaseName='c1_cag_tests' typo3DatabaseHost='localhost' typo3DatabaseUsername='username' typo3DatabasePassword='pw' \
bin/codecept run Acceptance -c web/typo3conf/ext/cag_tests/Resources/Core/Build/AcceptanceTests.yml
或者使用 PHPStorm。当然,您也可以使用 Chrome/Firefox 将 Codeception 与 Chrome/Firefox 一起用于小型演示,只需打开 Chrome 而不是以无头模式启动即可。这也可以用于错误查找...(配置在 Acceptance.suite.yml 中)
不要使用 Windows - 它可以工作,但是... :-|
简单地将 EXT:cag_tests/Resources/Private/Ext 文件夹复制出来,作为您自己的测试文件夹创建。调整 xml 测试配置文件中的固定值和路径以适应您的结构...然后可以开始测试了
有关在自定义扩展中测试的示例,请参阅 cag_wurmloch 中的内容 :-)
有关详细信息,请参阅 https://bitbucket.org/web-tp3/cag_tests/wiki/Home