Maven - Selenium - only one test can be run

We use JUnit - Selenium for our web tests. We use Maven to launch them and generate a confidence report.

The test suite is quite large and takes some time to run, and sometimes single tests fail because the browser does not start. I want to be able to run the SINGLE test using maven, so I am testing tests that do not work and update the report.

I can use mvn test -Dtest=TESTCLASSNAMEto run all the tests in one test class, but this is not very good, since it takes about 10 minutes to run all the tests in our most difficult test classes, and it is very likely that some other tests (because the browser will not start) and it will ruin my report.

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

Any help on this will be very helpful.

+5
source share
3 answers

C_maker's answer describes the main points - you really should consider splitting large test cases into several. I recommend TestNG or JUnit4 for Selenium tests so that you can easily manage the setup in front of the whole package, any test dependencies, and so on. In TestNG, you can also use groupto classify tests for a selective run, so you don't have to ignore them if you want to run a specific class of tests.

+2
source
  • , mvn test -Dtest = TESTCLASSNAME .

  • junit4, , , @Ignore.

  • onSetup() onTeardown(), , , . , .

+3

Maven Surefire Plugin, :

mvn -Dtest=TestCircle#mytest test

TestCircle - , mytest - .

Not directly related, but if you use Cucumber to run scripts, you can run one script in a single function file by doing the following:

mvn -P selenium,chrome -Dcucumber.options="classpath:com/my/package/myfeature.feature:47" clean verify

where line 47 is the start of the script you want to run, and chrome is your test browser profile.

0
source

All Articles