Answers for "junit testcase run in order"

1

junit testcase run in order

@TestMethodOrder(OrderAnnotation.class)
public class OrderAnnotationUnitTest {
    private static StringBuilder output = new StringBuilder("");
     
    @Test
    @Order(1)    
    public void firstTest() {
        output.append("a");
    }
     
    @Test
    @Order(2)    
    public void secondTest() {
        output.append("b");
    }
  
    @Test
    @Order(3)    
    public void thirdTest() {
        output.append("c");
    }
  
    @AfterAll
    public static void assertOutput() {
        assertEquals(output.toString(), "abc");
    }
}
Posted by: Guest on May-14-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language