How do I run all my PHPUnit tests?(如何运行我所有的 PHPUnit 测试?)
问题描述
我有一个名为 Script.php 的脚本并在 Tests/Script.php 中对其进行测试,但是当我运行 phpunit Tests 时,它不会在我的测试文件中执行任何测试.如何使用 phpunit 运行所有测试?
I have script called Script.php and tests for it in Tests/Script.php, but when I run phpunit Tests it does not execute any tests in my test file. How do I run all my tests with phpunit?
PHPUnit 3.3.17,PHP 5.2.6-3ubuntu4.2,最新的 Ubuntu
PHPUnit 3.3.17, PHP 5.2.6-3ubuntu4.2, latest Ubuntu
输出:
$ phpunit Tests
PHPUnit 3.3.17 by Sebastian Bergmann.
Time: 0 seconds
OK (0 tests, 0 assertions)
这是我的脚本和测试文件:
And here are my script and test files:
Script.php
<?php  
function returnsTrue() {  
    return TRUE;  
}  
?>
Tests/Script.php
<?php  
require_once 'PHPUnit/Framework.php';  
require_once 'Script.php'  
class TestingOne extends PHPUnit_Framework_TestCase  
{
    public function testTrue()
    {
        $this->assertEquals(TRUE, returnsTrue());
    }
    public function testFalse()
    {
        $this->assertEquals(FALSE, returnsTrue());
    }
}
class TestingTwo extends PHPUnit_Framework_TestCase  
{
    public function testTrue()  
    {  
        $this->assertEquals(TRUE, returnsTrue());  
    }
    public function testFalse()
    {
        $this->assertEquals(FALSE, returnsTrue());
    }
}  
?>
推荐答案
我创建了以下 phpunit.xml 现在至少我可以做到 phpunit --configuration phpunit.xml在我的根目录中运行位于 Tests/中的测试
I created following phpunit.xml and now atleast I can do phpunit --configuration phpunit.xml in my root directory to run the tests located in Tests/
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         syntaxCheck="false">
  <testsuites>
    <testsuite name="Tests">
      <directory suffix=".php">Tests</directory>
    </testsuite>
  </testsuites>
</phpunit>
                        这篇关于如何运行我所有的 PHPUnit 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何运行我所有的 PHPUnit 测试?
				
        
 
            
        基础教程推荐
- 将变量从树枝传递给 js 2022-01-01
 - Web 服务器如何处理请求? 2021-01-01
 - php中的PDF导出 2022-01-01
 - Yii2 - 在运行时设置邮件传输参数 2022-01-01
 - 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
 - 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
 - PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
 - php 7.4 在写入变量中的 Twig 问题 2022-01-01
 - php中的foreach复选框POST 2021-01-01
 - 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
				
				
				
				