Although that i'm using @FixMethodOrder(MethodSorters.NAME_ASCENDING)
My tests are not runing at the desired order
I have 2 tests,
The first tets name is: aTest_Login()
The second test name is: bTest_CreateContact()
Sometimes the second test is runing before the first test.
Without knowning details about @FixMethodOrder
, it seems to be a JUnit thing. JUnit is, as the name states, a framework to execute unit tests. Unit tests must not have any depenencies or links between them (that's the idea of unit tests), so the order in which they are executed must not influence the result, they are commutative. If you want to execute tests in a specific order for integration and gui tests I would strongly recommend to use something supporting test dependencies like Test NG
In TestNG you can define test groups and specify test dependencies. If you want to run gui tests the first "root" test could be whether or not your test system is online (because all you gui tests will fail if the system is offline it makes sense to only have one failed test, saying the system was offline).
@Test(groups = "login")
public void aTest_Login() {
...
}
@Test(groups = {"contacts", "creation"}, dependsOnGroups = "login")
public void bTest_CreateContact(){
// this test will only be executed if all tests of the group "login" passed
}
TestNG has a migration guide from JUnit and offers other stuff regarding integration- and gui tests. You should check it out