views:

297

answers:

2

Hi

We are using JUnit - Selenium for our web tests. We use Maven to start them and build a surefire report.

The test suite is pretty large and takes a while to run and sometimes single tests fail because the browser won't start. I want to be able run a SINGLE test using maven so I retest the tests that fail and update the report.

I can use mvn test -Dtest=TESTCLASSNAME to run all the tests in one test class, but this is not good enough since it takes about 10 minutes to run all the tests in our most complicated test classes and it's very likely that some other test will fail (because the browser wont start) and this will mess up my report.

I know I can run one test from Eclipse but that is not what I am looking for.

Any help on this would be very appriciated

+3  A: 
  1. You can have a parent class with common setup and a child class for each testcase, that way you can use mvn test -Dtest=TESTCLASSNAME to run a single test.

  2. If you are using junit4, you can annotate the methods you wish to ignore for the moment with @Ignore.

  3. If you do not have onSetup() and onTeardown() that needs to run for each testcase then you can make your test methods private and have only one testcase that call the others. This way it is easy to comment them out as needed.

c_maker
+2  A: 

c_maker's answer describes the main points - you really should consider breaking up the large test cases into multiple ones. I recommend TestNG or JUnit4 for Selenium tests so that you can easily manage the set up before the whole suite, any test dependencies, and so on. In TestNG, you can also use a group to classify tests to run selectively so that you don't need to set them to ignore when you want to run a particular class of tests.

Brett Porter