I'm not sure if this is the right place for this, but since Selenium is
involved I'm hoping someone can offer some advice!
Our test framework uses a combination of Selenium, Concordion and JUnit to
run browser based tests. Due to the way the framework was designed, each
'test' has its own *Test.java file (e.g. /src/spec/SomeWebTest.java) which
all inherit from the same class (e.g. /src/spec/BaseWebTest.java).
The problem we have with this is that Selenium opens a new browser instance
for every *Test.java file that JUnit runs, and closes it again at the end
of the test. We have around 1900 tests, each in their own class, which
means Selenium opening and closing Firefox over 1900 times for a full test
run. This wastes a huge amount of time essentially doing nothing (our test
suite currently takes around 8 hours for a full run).
I was hoping to use @BeforeClass to get Selenium to open a browser once,
then re-use that for every test in the suite, then using @AfterClass to
close the browser again at the end. But both @BeforeClass/@AfterClass
assume that methods marked with @Test all reside in the same class file,
which makes sense up to a point (though having 1900 @Test methods inside a
single class would be unwieldy).
The problem is, with our test suite, there's only a single @Test method in
each class file, so @BeforeClass/@AfterClass doesn't make any difference
and the browser still opens/closes with every test file.
Firstly, how do you work around this, or are you stuck in the same position
with hundreds of individual browser executions when running a suite? Or is
there a way to get JUnit to run some code before and after all of the
testing has happened (and obviously within the same JVM instance as the
tests themselves, so the WebDriver instance can be kept statically and
shared across all tests)?
I'd be grateful for any suggestions you have - our framework is due for a
complete rewrite anyway, its a few years old and breaking apart at the
seams, but without any time or resource to rewrite it any suggestions for
code improvements which reduce the running time would be greatly
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/45EiaysS_WMJ.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to firstname.lastname@example.org.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.