在TestSuite期间停止Phpunit执行
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了在TestSuite期间停止Phpunit执行,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2166字,纯文字阅读大概需要4分钟。
内容图文
![在TestSuite期间停止Phpunit执行](/upload/InfoBanner/zyjiaocheng/799/a468cff8c9074106b30b3efa06091afd.jpg)
我用一个类用PhpUnit执行一个测试套件,如:
$suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
$suite->addTestSuite('ClassOne');
$suite->addTestSuite('ClassTwo');
return $suite;
要开始单元测试:
# phpunit --stop-on-failure TestSuite.php
如果“ClassOne”有错误或异常,则测试继续“ClassTwo”.
如果第一次测试失败,我怎么能阻止所有的测试?
解决方法:
适用于PHPUnit 3.5.14
使用下面的代码输出是预期的:
两个正常运行失败:
phpunit AllTests.php
PHPUnit 3.5.14 by Sebastian Bergmann.
FF
Time: 0 seconds, Memory: 6.25Mb
There were 2 failures:
1) Framework_AssertTest::testFails
Failed asserting that <boolean:true> matches expected <boolean:false>.
/home/edo/test/AllTests.php:7
2) Other_AssertTest::testFails
Failed asserting that <boolean:true> matches expected <boolean:false>.
/home/edo/test/AllTests.php:13
FAILURES!
Tests: 2, Assertions: 2, Failures: 2.
并且一个用–stop-on-failure运行它失败了
phpunit --stop-on-failure AllTests.php
PHPUnit 3.5.14 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 6.25Mb
There was 1 failure:
1) Framework_AssertTest::testFails
Failed asserting that <boolean:true> matches expected <boolean:false>.
/home/edo/test/AllTests.php:7
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
AllTests.php
<?php
class Framework_AssertTest extends PHPUnit_Framework_TestCase {
public function testFails() {
$this->assertSame(false, true);
}
}
class Other_AssertTest extends PHPUnit_Framework_TestCase {
public function testFails() {
$this->assertSame(false, true);
}
}
class Framework_AllTests
{
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
$suite->addTestSuite('Framework_AssertTest');
$suite->addTestSuite('Other_AssertTest');
return $suite;
}
}
class Other_AllTests
{
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
$suite->addTestSuite('Other_AssertTest');
return $suite;
}
}
class AllTests
{
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('PHPUnit');
$suite->addTest(Framework_AllTests::suite());
return $suite;
}
}
作为侧节点.如果你看一下documentation of the current version只有“suite by file system”和“suite by xml config”的解释选项.如果您可以在此时迁移,请记住这一点.
内容总结
以上是互联网集市为您收集整理的在TestSuite期间停止Phpunit执行全部内容,希望文章能够帮你解决在TestSuite期间停止Phpunit执行所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。