Priority in TestNG with multiple classes

后端 未结 6 1001
再見小時候
再見小時候 2020-11-27 20:15

I\'m facing with the following problem: I created two classes which include @Tests with priority attribute:

@Test( priority = 1 )
public void testA1() {
             


        
6条回答
  •  醉梦人生
    2020-11-27 20:55

    Group the test methods of first class and put dependsOnGroups in test methods of 2nd class.So execution will be proper as per the expectation shown below

    ClassOne is as follows

        @Test( priority = 1,groups="FirstClass" )
        public void testA1() {
            System.out.println("testA1");
        }
    
        @Test( priority = 2,groups="FirstClass" )
        public void testA2() {
            System.out.println("testA2");
        }
    
        @Test( priority = 3,groups="FirstClass" )
        public void testA3() {
            System.out.println("testA3");
        }
    

    ClassTwo is as follows

        @Test( priority = 1,dependsOnGroups="FirstClass")
        public void testB1() {
            System.out.println("testB1");
        }
    
        @Test( priority = 2,dependsOnGroups="FirstClass" )
        public void testB2() {
            System.out.println("testB2");
        }
    
        @Test( priority = 3,dependsOnGroups="FirstClass" )
        public void testB3() {
            System.out.println("testB3");
        }
    

    And Finally testng.xml is

    
      
        
          
          
        
       
     
    
    

    It gives the same output as per priority given in both the classes and order also

提交回复
热议问题