您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit报告测试执行进度teamcity参数的使用
发布时间:2021-09-12 16:49:04编辑:雪饮阅读()
像是假如我们有一个单元测试:StackTest.php
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class StackTest extends TestCase
{
public function testPushAndPop(): void
{
$stack = [];
$this->assertSame(0, count($stack));
array_push($stack, 'foo');
$this->assertSame('foo', $stack[count($stack)-1]);
$this->assertSame(1, count($stack));
$this->assertSame('foo', array_pop($stack));
$this->assertSame(0, count($stack));
}
}
use PHPUnit\Framework\TestCase;
final class StackTest extends TestCase
{
public function testPushAndPop(): void
{
$stack = [];
$this->assertSame(0, count($stack));
array_push($stack, 'foo');
$this->assertSame('foo', $stack[count($stack)-1]);
$this->assertSame(1, count($stack));
$this->assertSame('foo', array_pop($stack));
$this->assertSame(0, count($stack));
}
}
那么对于这个单元测试类在命令行中测试有如:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.3.4nts\php.exe D:\phpstudy_pro\Extensions\php\php7.3.4nts\phpunit-9.5.8.phar --no-configuration C:\Users\Administrator\PhpstormProjects\untitled\StackTest.php
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 00:00.002, Memory: 20.00 MB
OK (1 test, 5 assertions)
这样看到的测试进度其实比较简单(还有更简单的就是--no-configuration参数都不带),如果想要查看比较详细,比较细致的测试进度则可以利用teamcity参数:
--teamcity:以TeamCity格式报告测试执行进度
那么结合teamcity参数之后我们的测试命令执行如:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.3.4nts\php.exe D:\phpstudy_pro\Extensions\php\php7.3.4nts\phpunit-9.5.8.phar --no-configuration C:\Users\Administrator\PhpstormProjects\untitled\StackTest.php --teamcity
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
##teamcity[testCount count='1' flowId='572']
##teamcity[testSuiteStarted name='StackTest' locationHint='php_qn://C:\Users\Administrator\PhpstormProjects\untitled\StackTest.php::\StackTest' flowId='572']
##teamcity[testStarted name='testPushAndPop' locationHint='php_qn://C:\Users\Administrator\PhpstormProjects\untitled\StackTest.php::\StackTest::testPushAndPop' flowId='572']
##teamcity[testFinished name='testPushAndPop' duration='0' flowId='572']
##teamcity[testSuiteFinished name='StackTest' flowId='572']
Time: 00:00.004, Memory: 20.00 MB
OK (1 test, 5 assertions)
这就是teamcity参数的使用。
关键字词:phpunit,teamcity
上一篇:使maven项目支持eclipse并导入eclipse
下一篇:phpunit测试的依赖关系(depends)及assertEmpty,assertSame,assertNotEmpty的使用