0
votes

It got an error as I follow the guide of netbeans.

It says: Perhaps an error occurred, verify in Output window.

In output:

No tests executed.(0.0 s)

The code is like this:

<?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;
    }
}
?>

Here is the generated file form 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)
        );
    }

}

I use XAMPP 32bit + Netbeans on windows

What's wrong with it?

2

2 Answers

0
votes

I found the problem!

I simply add a row in the generated php:

require '../Calculator.php';

so, that works fine.

However that's troublesome, any way to due with that?

Still questioning. :)

0
votes

You can set up bootstrap with autoloader for PHPUnit