Reputation: 164909
I'm using PHPUnit's Selenium extension to do web testing. I'm finding it very slow, taking seconds for a single test method. Part of the issue appears to be that its starting a new Selenium session between each test method (getNewBrowserSession), as part of runTest(). This is expensive. I'm ok with running a class or even a whole suite's worth of test methods in a single selenium session.
Can this be done? Are there other tips for speeding up PHPUnit + Selenium?
Thanks.
Upvotes: 3
Views: 2231
Reputation: 17366
Have you tried using the browserSessionReuse option? E.g. starting selenium with
java -jar ./selenium-server.java -browserSessionReuse
Upvotes: 9
Reputation: 471
I'd suggest you to build Continous Integration system to run test at night. Then at morning you will have information what test are ok and what no. Check Hudson.
Upvotes: 0
Reputation: 17828
You need to share the Selenium instance between your tests. I am not familiar with PHPUnit, but in JUnit you use static member (create a base test class that holds the Selenium instance and all tests should extend it). In TestNG you can use test context.
Also try to minimize the usage of XPath if you test on IE - absence of native XPath makes tests run slower.
Also Selenium 1 uses JavaScript to drive the browser, so it is somewhat slow on IE. Selenium 2 (aka WebDriver) uses native methods to drive the browser, so at least IE tests are faster.
Upvotes: 1