maven - How do I control order of test execution within a single integration test file? -



maven - How do I control order of test execution within a single integration test file? -

i’m using maven 3.0.3, failsafe plugin v2.17 , junit 4.11. have integration test tests in next order

@runwith(springjunit4classrunner.class) public class mytests { @test public final void testadd() { … } @test public final void testupdate() { … } @test public final void testdelete() { … }

currently when run tests through maven part of “mvn clean install” run, “testdelete” getting run before “testadd” or “testupdate”. if alter name “testzzzdelete”, gets run lastly don’t that.

how tests run in order specify them in file? failsafe configuration so:

<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-failsafe-plugin</artifactid> <version>2.17</version> <configuration> <reuseforks>true</reuseforks> <argline>-xmx4096m -xx:maxpermsize=512m ${itcoverageagent}</argline> </configuration> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin>

short answer: no, there isn't anyway apart renaming tests execute in order. can utilize @fixmethodorder(name_ascending) annotation ensure tests are executed in alphabetical order.

long answer: i'm sure know, surefire/failsafe gives alternative of ordering test classes through runorder configuration parameter. controls order in each test class executed. can run class foobar.test1 before foobar.test2 or other way around.

for order of execution of methods within class, problem facing jvm doesn't homecoming list of methods in same order declared in file. java 6, order in returned order of declaration, changed java 7. so, release of junit 4.11, default ordering changed based on hash of method name, give deterministic, not predictable ordering. why getting testdelete run before else.

after long discussion, added fixmethodorder annotation junit 4.11 allow @ to the lowest degree able rename methods. seems work springjunit4classrunner - @ to the lowest degree latest version 4.1.0.release. haven't tried other releases.

so, have predictable ordering, could, necessary, rename methods executed in order want , add together @fixmethodorder annotation class.

@runwith(springjunit4classrunner.class) @fixmethodorder(methodsorters.name_ascending) public class mytests { @test public final void step1add() { … } @test public final void step2update() { … } @test public final void step3delete() { … }

for more information, please see has junit4 begun supporting ordering of test? intentional?.

maven junit order integration-testing maven-failsafe-plugin

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -