Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

annotation @depends does not work #82

Closed
emaks opened this issue Jan 10, 2012 · 7 comments
Closed

annotation @depends does not work #82

emaks opened this issue Jan 10, 2012 · 7 comments

Comments

@emaks
Copy link
Contributor

emaks commented Jan 10, 2012

if extends test class from PHPUnit/Extensions/SeleniumTestCase annotation @Depends does not work

test example:

class test extends PHPUnit_Extensions_SeleniumTestCase
{

function setUp()
{
    $this->setBrowser("*firefox");
    $this->setBrowserUrl("http://www.google.com.ua/");
}

/**
 * @test
 * @return string
 */
public function testOne()
{
    $this->open("http://www.google.com.ua/");
    $title = $this->getTitle();
    return $title;
}

/**
 * @test
 * @depends testOne
 *
 * @param $expectedTitle
 */
public function testTwo($expectedTitle)
{
    $this->open("http://www.google.com.ua/");
    $actualTitle = $this->getTitle();
    $this->assertEquals($expectedTitle, $actualTitle);
}

}

result:

PHPUnit 3.6.7 by Sebastian Bergmann.

PHPUnit_Framework_Error_Warning : Missing argument 2 for PHPUnit_Framework_Error::__construct(), called in home\PEAR\PHPUnit\Extensions\SeleniumTestCase.php on line 1110 and defined
#0 home\PEAR\PHPUnit\Framework\Error.php(69): PHPUnit_Util_ErrorHandler::handleError(2, 'Missing argumen...', 'C:\wamp\bin\php...', 69, Array)
#1 home\PEAR\PHPUnit\Extensions\SeleniumTestCase.php(1110): PHPUnit_Framework_Error->__construct('Current URL: ht...')
#2 home\PEAR\PHPUnit\Framework\TestCase.php(910): PHPUnit_Extensions_SeleniumTestCase->onNotSuccessfulTest(Object(PHPUnit_Framework_Error_Warning))
#3 home\PEAR\PHPUnit\Framework\TestResult.php(649): PHPUnit_Framework_TestCase->runBare()
#4 home\PEAR\PHPUnit\Extensions\SeleniumTestCase.php(561): PHPUnit_Framework_TestResult->run(Object(test))
#5 home\PEAR\PHPUnit\Framework\TestSuite.php(772): PHPUnit_Extensions_SeleniumTestCase->run(Object(PHPUnit_Framework_TestResult))
#6 home\PEAR\PHPUnit\Framework\TestSuite.php(745): PHPUnit_Framework_TestSuite->runTest(Object(test), Object(PHPUnit_Framework_TestResult))
#7 home\PEAR\PHPUnit\TextUI\TestRunner.php(325): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult), false, Array, Array, false)
#8 home\PEAR\PHPUnit\TextUI\Command.php(187): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#9 home\ide-phpunit.php(194): PHPUnit_TextUI_Command->run(Array, true)
#10 home\ide-phpunit.php(386): IDE_PHPUnit_TextUI_Command::main()
#11 {main}

Time: 31 seconds, Memory: 5.75Mb

FAILURES!
Tests: 2, Assertions: 0, Errors: 1.

Process finished with exit code 2

@giorgiosironi
Copy link
Owner

I've integrated your test and replicated the bug. The problem is the suite creation code is a mess, because it overrides the standard one to provide support for multiple browsers and Selenese tests; it will take a while to refactor it.

@emaks
Copy link
Contributor Author

emaks commented Jan 16, 2012

Could you please define when will exactly this bug be fixed? This action is very important for my project. Thank you in advance.

@giorgiosironi
Copy link
Owner

This bug is now fixed in master. If you want it fixed before the next minor release, patch your PHPUnit_Extensions_SeleniumTestCase.php file.

@emaks
Copy link
Contributor Author

emaks commented Jan 18, 2012

After applying these changes annotation @Depends began working, but the whole work still has bugs:
Variables transmission between the tests doesn't work (value of the sent variables is always NULL)

TEST:

class dependsTest extends PHPUnit_Extensions_SeleniumTestCase
{
protected function setUp()
{
$this->setBrowser("*firefox");
$this->setBrowserUrl("http://localhost/");
}

/**
 * @test
 * @return string 
 */
public function first()
{
    return 'testMyTestCase text';
}

/**
 * @test
 * @depends first
 * @param string $param 
 */
public function second($param)
{
    var_dump($param);
}

}

RESULT:
PHPUnit 3.6.7 by Sebastian Bergmann.

..NULL

Time: 29 seconds, Memory: 5.75Mb

OK (2 tests, 0 assertions)

@giorgiosironi giorgiosironi reopened this Jan 18, 2012
@giorgiosironi
Copy link
Owner

After delegating a bit more to PHPUnit_Framework_TestCase, the test now passes (using assertSame instead of assertEquals to check the string is passed between tests.) If you find other failures of @Depends, please report them and reopen the issue.

@Mordred
Copy link

Mordred commented Jun 11, 2012

Can you fix this also in the Selenium2TestCase ?

@giorgiosironi
Copy link
Owner

I wasn't aware it was not working in there, thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants