作用
前提
安装
安装xUnit插件
win10重启Jenkins
全局环境设置
创建项目配置
描述
源码管理
构建触发器
构建步骤
插件安装
工作空间
php代码phpunit文件示例
项目根目录配置
phpunit.xml
Protect/Tests/test_start.php
composer.json
项目根目录配置
phpunit.xml
<phpunit bootstrap="protect/Tests/test_start.php" colors="true">
<testsuites>
<testsuite name="unit">
<directory>protect/Tests/Unit</directory>
<directory>protect/Tests/Api</directory>
</testsuite>
</testsuites> <filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">protect/Biz</directory>
<directory suffix=".php">protect/Service</directory>
<directory suffix=".php">protect/EntityService</directory>
</whitelist>
</filter> <logging>
<log type="coverage-html" target="./reports" lowUpperBound="100" highLowerBound="100"/>
</logging>
</phpunit>
Protect/Tests/test_start.php
<?php/**
* Author: wang.kai
* Date: 2023/07/06
* Time: 11:36 AM
*/$hllEnv = get_cfg_var('dh.env'); //当前部署环境(在php.ini中定义)
$hllEnv or $hllEnv = 'dev';
define('DH_ENV', strtolower($hllEnv)); //dev/stg/prd/gra
define('DH_IS_DEV', $hllEnv == 'dev');
if ($hllEnv != "dev") {
exit();
}
require(__DIR__.'/../../vendor/autoload.php');
composer.json
{
"name": "test/public-test",
"description": "Protect/Tests",
"require-dev": {
"phpunit/phpunit": "6.2.4"
},
"require": {
"php": "^7.0",
"ext-json": "*",
"ext-curl": "*",
"ext-redis": "*"
},
"autoload": {
"psr-4": {
"App\\": "Protect/"
},
"classmap": [
]
}
}
安装phpunit
Composer install
如果修改了composer配置
composer dump-autoload
发表评论 取消回复