我有一个脚本叫做脚本.php及其在tests/Script中的测试.但是当我运行phpunit测试时,它不会在我的测试文件中执行任何测试.如何使用phpunit运行所有测试?

PHPUnit 3.3.17,php5.2.6-3ubuntu4.2.最新的Ubuntu

Output:

$ phpunit Tests
PHPUnit 3.3.17 by Sebastian Bergmann.
Time: 0 seconds
OK (0 tests, 0 assertions)

以下是我的脚本和测试文件:

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个,以运行位于测试中的测试/

<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         syntaxCheck="false">
  <testsuites>
    <testsuite name="Tests">
      <directory suffix=".php">Tests</directory>
    </testsuite>
  </testsuites>
</phpunit>

Linux相关问答推荐

Linux在所有多行中用新值替换整个列

如何检测文件系统是否支持权限?

BASH:在curl输出的每一行添加前缀

命令行中使用`..`为什么会导致权限被拒绝错误?

如何让xargs对 bash 脚本中find命令找到的所有文件执行?

awk 打印除最后一列以外的所有内容 + 最后一列

在 Ubuntu 中,如何设置 Tomcat 9 以使用 Java 17?

使用 AWK 过滤 Linux 输出

bash 更有效的方法来转换奇数日期格式以被 linux 日期识别

从 .war 文件外部化 Tomcat webapp 配置

如何将执行的shell命令的结果存储在python的变量中?

如何计算列的平均值

C hello world 的汇编输出的每一行是什么意思?

Linux 上 pid_t、uid_t、gid_t 的大小

使用特定目录作为根目录压缩目录的命令

scp 使用私钥身份验证将目录复制到另一台服务器

使远程目录保持最新

在 Emacs 中匹配括号的命令是什么?

try 使用 sudo 将文件附加到根拥有的文件时权限被拒绝

带有日期和时间的 Linux 命令历史记录