0

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 32ビット+ Netbeansを使用しています

どうしたの?

4

2 に答える 2

0

PHPUnitのオートローダーでブートストラップを設定できます

于 2014-12-07T22:21:01.070 に答える
0

問題が見つかりました!

生成された php に行を追加するだけです。

require '../Calculator.php';

それで、それはうまくいきます。

面倒だけどそれでどうにかならないの?

まだ質問中です。:)

于 2013-10-25T08:45:24.403 に答える