Hi,
i have a folder in testcase which contains several testcases and i want to run them in certain order.
structure of my testcase is:
Test Cases
-Folder1
-testcase1_runner
-testcase2
-testcase3
-testcase4
-testcase5
-testcase_final
So what i want run testcase1_runner which will execute:
testcase_1
tescase_2
testcase_final
then
testcase_1
testcase_3
testcase_final
then
testcase_1
testcase_4
testcase_final
Is there a way to do it with a loop?
im trying with this:
//1- run testcase1
WebUI.callTestCase(findTestCase(âFolder1/testcase1â), [:], FailureHandling.STOP_ON_FAILURE)
Youâre probably already taking the best approach. Hereâs whyâŚ
A Test Case needs to be READABLE. It should be very clear, even to the casual reader, what it is trying to achieve.
Could you (or anyone) write a super intelligent procedure that computes âwhat is nextâ and stick it in a loop? Absolutely. But would it be readable?
Now think about the only constant in testing (or anything for that matter)⌠the requirements will change. Change, as we all know, is a constant.
When you come to modify your chosen structure and approach, which one do you think is the easiest to modify? What if the person making the change is not you?
The only other thing you might consider is to add the tests, in the order you wish them to execute, to a suite. But really, thereâs nothing wrong with callTestCase() and a master test case.
Aside: There has been talk about ad hoc suite creation where a suite is created in memory (via code) and executed. I havenât heard when that might appear but I live in hope. (hint hint @ThanhTo)
If you get rid of your existing instance of Junit, and download JUnit 4.11 or greater in the build path, the following code will execute the test methods in the order of their names, sorted in ascending order:
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SampleTest {
@Test
public void testAcreate() {
System.out.println("first");
}
@Test
public void testBupdate() {
System.out.println("second");
}
@Test
public void testCdelete() {
System.out.println("third");
}