开发者

How to run a test in PHPUnit+Selenium?

I have everything installed and I am able to create and run tests in NetBeans fine by right clicking the test in the project menu and selecting "Run". The problem is that the browser windows opened for the test close immediately after the test is ran - meaning that the only reporting I have is what NetBeans provides and that's not enough. I d开发者_如何学JAVAon't think I want to use the command line, plus I haven't had much success with it in the past anyways.

Is it possible to just point the browser at the test.php file? When i try to do that I get this error:

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in C:\xampp\php\PEAR\PHPUnit\Extensions\SeleniumTestCase.php on line 275

Shouldn't i be able to execute these test from a different machine? ie PC1 is my dedicated selenium test box and I want to tell it to run test.php from PC2 remotely.

Where should my test files go?

How do I customize the reporting/out put from the test script?


You could add a sleep(60) at the end of your test :) This would prevent PHPUnit from closing the Selenium session.

Alternatively, store your selenium tests as html files compatible with the Selenium IDE Firefox extension and let the test simply run in your browser.


I found out how to run my test files remotely - i just created a script that would execute phpunit from the command line:

<?php
exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output);
    echo "<pre>".  var_export($output,TRUE)."</pre>";
    exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output);
    echo "<pre>".  var_export($output,TRUE)."</pre>";
    ?>

then I can just hit the URL of that script to have it run - works great, but I still think there should be a better/easier way...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜