junit test suite Suite

 

  junit test kit, a test is run such a class or classes are some test junit test run

  See Code:

  Test suite categories:

  

Copy the code
Import org.junit.runner.RunWith;
 Import org.junit.runners.Suite; 

@RunWith (. Suite class ) 
@ Suite.SuiteClasses ({Task1Test. class , Task2Test. class , Task3Test. class })
 public  class SuiteTest { 

    / * * 
     * 1. run with a test suite is to organize the test class 
     * 
     * write a test suite as an entry class, this class does not include other methods 
     * change the test runner Suite.classes, will be tested as an array passed to the class Suite.SuiteClasses ({}) 
     * / 
    
}
Copy the code

  To test run with the test class has Task1Test, Task2Test, Task3Test

  Task1Test, Task2Test, Task3Test codes are as follows:

  

Copy the code
import org.junit.Test;

public class Task1Test {

    @Test
    public void test() {
        System.out.println("this is task1test");
    }

}
Copy the code
Copy the code
import org.junit.Test;

public class Task2Test {

    @Test
    public void test() {
        System.out.println("this is task2test");
    }

}
Copy the code
Copy the code
import org.junit.Test;

public class Task3Test {

    @Test
    public void test() {
        System.out.println("this is task3test");
    }

}
Copy the code

  Right-class test suite run as -> Junit Test

  Test results are as follows

  

  

  Similarly, the test can be nested nested class test nested class

  

  If wrong, please correct me!

  

Original Address: https: //www.cnblogs.com/xgh-space/p/9361165.html

 

  junit test kit, a test is run such a class or classes are some test junit test run

  See Code:

  Test suite categories:

  

Copy the code
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({Task1Test.class,Task2Test.class,Task3Test.class})
public class SuiteTest {

    /**
     * 1.测试套件就是组织测试类一起运行的
     * 
     * 写一个作为测试套件的入口类,这个类里不包含其他的方法
     * 更改测试运行器Suite.classes,将要测试的类作为数组传入到Suite.SuiteClasses({})
     */
    
}
Copy the code

  要一起测试运行的测试类有Task1Test、Task2Test、Task3Test

  Task1Test、Task2Test、Task3Test代码分别如下:

  

Copy the code
import org.junit.Test;

public class Task1Test {

    @Test
    public void test() {
        System.out.println("this is task1test");
    }

}
Copy the code
Copy the code
import org.junit.Test;

public class Task2Test {

    @Test
    public void test() {
        System.out.println("this is task2test");
    }

}
Copy the code
Copy the code
import org.junit.Test;

public class Task3Test {

    @Test
    public void test() {
        System.out.println("this is task3test");
    }

}
Copy the code

  Right-class test suite run as -> Junit Test

  Test results are as follows

  

  

  Similarly, the test can be nested nested class test nested class

  

  If wrong, please correct me!

  

Guess you like

Origin www.cnblogs.com/jpfss/p/10985735.html