php - 如何运行我所有的 PHPUnit 测试?

我有一个名为 Script.php 的脚本并在 Tests/Script.php 中对其进行测试,但是当我运行 phpunit Tests 时,它不会在我的测试文件中执行任何测试。如何使用 phpunit 运行所有测试?

PHPUnit 3.3.17,PHP 5.2.6-3ubuntu4.2,最新的 Ubuntu

输出:

$ 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());
    }
}  
?>

最佳答案

php 测试的文件名必须以 Test.php 结尾

phpunit mydir 将运行目录 mydir 中所有名为 xxxxTest.php 的脚本

(看起来好像没有在 phpunit 文档中描述)

https://stackoverflow.com/questions/1414125/

相关文章:

linux - 在所有子目录上使用 wc 来计算行数

java - 无法在 Android Studio 中清理项目

linux - 用于将文件夹从本地计算机复制到远程服务器的 scp 命令语法

linux - 如何找到只对所有者具有特定权限的文件?

linux - 如何在 Unix 中获取 GMT 时间?

linux - 命令行 Arduino 编译和上传?

linux - 使远程目录保持最新

linux - docker-compose up 导致 "client and server do

linux - 一个进程如何拦截Linux上另一个进程的stdout和stderr?

c++ - 从线程内 fork 是否安全?