PHP 调试 - Netbeans with PHPUnit - 未执行任何测试.(0.0 秒)


PHP debuging - Netbeans with PHPUnit - No tests executed.(0.0 s)

当我遵循netbeans的指南时,它遇到了错误。

它说:也许发生了错误,请在输出窗口中验证。

在输出中:

未执行任何测试。(0.0 秒)

代码是这样的:

<?php
class Calculator
{
    /**
     * @assert (0, 0) == 0
     * @assert (0, 1) == 1
     * @assert (1, 0) == 1
     * @assert (1, 1) == 2
     * @assert (1, 2) == 4
     */
    public function add($a, $b)
    {
        return $a + $b;
    }
}
?>

下面是从 NetBeans 生成的文件。

<?php
/**
 * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-10-25 at 15:06:25.
 */
class CalculatorTest extends PHPUnit_Framework_TestCase {
    /**
     * @var Calculator
     */
    protected $object;
    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp() {
        $this->object = new Calculator;
    }
    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown() {
    }
    /**
     * Generated from @assert (0, 0) == 0.
     *
     * @covers Calculator::add
     */
    public function testAdd() {
        $this->assertEquals(
                0
                , $this->object->add(0, 0)
        );
    }
    /**
     * Generated from @assert (0, 1) == 1.
     *
     * @covers Calculator::add
     */
    public function testAdd2() {
        $this->assertEquals(
                1
                , $this->object->add(0, 1)
        );
    }
    /**
     * Generated from @assert (1, 0) == 1.
     *
     * @covers Calculator::add
     */
    public function testAdd3() {
        $this->assertEquals(
                1
                , $this->object->add(1, 0)
        );
    }
    /**
     * Generated from @assert (1, 1) == 2.
     *
     * @covers Calculator::add
     */
    public function testAdd4() {
        $this->assertEquals(
                2
                , $this->object->add(1, 1)
        );
    }
    /**
     * Generated from @assert (1, 2) == 4.
     *
     * @covers Calculator::add
     */
    public function testAdd5() {
        $this->assertEquals(
                4
                , $this->object->add(1, 2)
        );
    }
}

我在Windows上使用XAMPP 32bit + Netbeans

怎么了?

我发现了问题!

我只是在生成的 php 中添加一行:

需要"../计算器.php';

所以,这工作正常。

然而,这很麻烦,有什么办法吗?

还在质疑。 :)

您可以使用 PHPUnit 的自动加载器设置引导程序