How to exclude class in TestNG?

后端 未结 8 1238
囚心锁ツ
囚心锁ツ 2020-12-30 05:17

Is this possible to exclude classes in testng.xml?

I tried with


    

         


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-30 06:03

    According to the TestNG dtd, the exclude element is only applicable to the following elements:

    • package - The package description within packages list.
    • methods - The list of methods to include/exclude from this test.
    • run - The subtag of groups used to define which groups should be run.

    The elements classes and class cannot be directly excluded; however, you can exclude classes through groups:

    @Test(groups = { "ClassTest1" })
    public class Test1 {
    
      public void testMethod1() {
      }
    
      public void testMethod2() {
      }
    
    }
    

    Then you will define the testng.xml:

    
      
        
          
            
          
        
        
          
        
       
    
    

    In most cases you define, which classes to include for the run, not to exclude, so just include the classes you want to run.

提交回复
热议问题