Welcome Guest, Not a member yet? Register   Sign In
fooStack and provider annotation doesnt work
#1

[eluser]MDomansky[/eluser]
Code:
<?
include_once dirname(__FILE__).'/../CIUnit.php';

class testMathAPI extends CIUnit_TestCase
{
    /**
    * @dataProvider provider2
    */
    public function testSolve2($a, $b, $c, $res)
    {
        $this->assertEquals($a+$b+$c, $res);
    }
    public function provider2()
    {
        return array(
            array(1, 0, -4, -3),
            array(1, 0, -144, -143),
            array(0, 0, -4, 4),
            array(1, 0, 4, false)
        );
    }
}
?>

i run it as
Code:
phpunit --verbose path/to/tests/testMathAPI.php

And I get errors like this
Code:
Message: Missing argument 1 for testMathAPI::testSolve2()


How can I use fooStack like phpunit?
#2

[eluser]TheFuzzy0ne[/eluser]
[quote author="MDomansky" date="1238763155"]
Code:
Message: Missing argument 1 for testMathAPI::testSolve2()
[/quote]

I am not familiar with FooStack, so I can't really comment, but that message just means that you haven't passed enough parameters over to the testSolve2() method.

[quote author="MDomansky" date="1238763155"]How can I use fooStack like phpunit?[/quote]

Can't you run PHPUnit instead?
#3

[eluser]MDomansky[/eluser]
phpunit execute 4 tests of testSovve2 by given elements of array (provider2)

But, I can't create tests for CI app without fooStack (
#4

[eluser]rafsoaken[/eluser]
[quote author="MDomansky" date="1238771349"]phpunit execute 4 tests of testSovve2 by given elements of array (provider2)

But, I can't create tests for CI app without fooStack ([/quote]

Hi MDomansky,
Somehow the custom __construct() method of the CIUnit_Testcase troubles phpUnit which should not be the case - so that might be a bug in phpUnit.
If you do not need CIUnit features other than access to your codeigniter object, you can simply use the PHPUnit_Framework_TestCase to extend from and in your setUp method assign the $this->CI controller object like so:
Code:
include_once dirname(__FILE__).'/../CIUnit.php';


class testPHPUnitFeatures extends PHPUnit_Framework_TestCase {

    function setUp()
    {
        $this->CI = &get;_instance();
    }

    /**
    * @dataProvider provider2
    */
    public function testSolve2($a, $b, $c, $res)
    {
        $this->assertEquals($a+$b+$c, $res);
    }

    public function provider2()
    {
        return array(
            array(1, 0, -4, -3),
            array(1, 0, -144, -143),
            array(0, 0, -4, 4),
            array(1, 0, 4, false)
        );
    }

}

Hope that helps for now.
raf
#5

[eluser]MDomansky[/eluser]
Thank you, raf

The way you proposal works fine )
#6

[eluser]rafsoaken[/eluser]
I now added a workaround in the CIUnit_TestCase constructor. With the latest repository version you can now use the usual CIUnit_TestCase.

cheers
raf




Theme © iAndrew 2016 - Forum software by © MyBB