PHPUnit - 忽略数据提供程序的测试

时间:2017-04-20 18:17:28

标签: phpunit

我有一个具有两个测试的特征,每个测试都有一个单独的数据提供者:

<?php 
$listed = get_post_meta($post->ID,'listed',true);

$broker = get_post_meta($post->ID,'broker',true);

if( $listed && $broker ){

if( $listed == 'Sold' ) { echo ' <div class="more-information">Sold By</div><li> [broker]    [officephone]   </li>'; }
if( $listed == 'For Sale' ) { echo ' <div class="more-information">Contact Information </div><li> [broker]    [officephone]   </li>'; }
if( $listed == 'Not For Sale' ) { echo ' <div class="more-information">Last Active Agent </div><li> [broker]    [officephone]   </li>'; }
if( $listed == 'Contingent or Pending Sale' ) { echo ' <div class="more-information">If interested, contact agent for current status. </div><li> [broker]    [officephone]   </li>'; }
if( $listed == 'Demolished' ) { echo ' '; } 
} ?>

我的测试类包含要使用trait StringTest { /** * @dataProvider stringProvider */ public function testString($expression, $string) { //echo $name; $this->assertInternalType('string', $string, "Not a string."); $this->assertRegExp($expression, $string); } /** * @dataProvider nonmatchingStringProvider */ public function testNonmatchingString($expression, $string) { //echo $name; $this->assertInternalType('string', $string, "Not a string."); $this->assertNotRegExp($expression, $string); } } 但不能使用testString进行测试的案例。当我没有nonmatchingStringProvider的任何情况时,我想完全忽略testNonmatchingString。完全忽略。不报告任何类型的错误,警告或跳过。 (在this case中,开发人员接受了一个解决方案,将测试标记为已跳过。此处不接受跳过。)

我可以把这个特性分成两个不同的特征。我宁愿不这样做。

是否可以通过省略类中的nonmatchingStringProvider或定义nonmatchingStringProvider并让它返回一个空数组来编码或配置phpunit以这种方式运行?

0 个答案:

没有答案
相关问题