Reputation: 1457
My code will be like below:
1.methodfortestcase1() 2.testcase1() 3.methodefortestcase2() 4.testcase2()
Upvotes: 0
Views: 279
Reputation: 1210
If you are using JUnit4 to run testcase you can use the following annotation to run your testcases:
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FixMethodOrder(MethodSorters.JVM)
@FixMethodOrder(MethodSorters.DEFAULT)
And If you are running it using JUnit3, mind that the testcases are called in alphabetical order of their names and 'test' prefix is must for naming the testcases. Many Experts say that it is always better to write independent testcases. Your testcase should not depend on each other. Your testcases should be robust enough to be orderless to test your application code in a better way. Then only you will come to know where your code is lacking!
Upvotes: 0
Reputation: 300
To get the desired result you'll likely have to use a combination of @Test(priority)
and dependsOnMethods
. Keep in mind that when using dependsOnMethods
that if a dependency method fails, the dependents will not be run.
Upvotes: 2
Reputation: 410
Use @Test (priority ) annotation. The lower priorities will be scheduled first.
Upvotes: 3