【问题标题】:PHP debuging - Netbeans with PHPUnit - No tests executed.(0.0 s)PHP 调试 - 带有 PHPUnit 的 Netbeans - 未执行测试。(0.0 秒)
【发布时间】:2013-11-04 04:50:15
【问题描述】:

当我关注 netbeans 的 guide 时出现错误。

它说:可能发生了错误,在输出窗口中验证。

在输出中:

未执行任何测试。(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 testing netbeans phpunit


    【解决方案1】:

    我发现了问题!

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

    需要'../Calculator.php';

    所以,效果很好。

    但是这很麻烦,有什么办法吗?

    仍在质疑。 :)

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-07-17
        • 1970-01-01
        • 2018-05-05
        • 1970-01-01
        • 2015-06-15
        • 2018-10-08
        • 2013-04-10
        • 1970-01-01
        相关资源
        最近更新 更多