霍格沃兹测试开发学社
ceshiren.com
package class1;
import org.junit.jupiter.api.*;
public class Base1Test {
@BeforeAll
public static void beforeAll1(){
// System.out.println("Base1Test---beforeAll1 执行!");
System.out.println("我要去上大学去了!");
}
@AfterAll
public static void afterAll1(){
// System.out.println("Base1Test---afterAll 执行!");
System.out.println("我毕业啦!");
}
@BeforeEach
public void beforEach1(){
// System.out.println("Base1Test---BeforeEach 执行!");
System.out.println("要开始进行升级考试啦!");
}
@AfterEach
public void afterEach1(){
// System.out.println("Base1Test---AfterEach 执行!");
System.out.println("我考试通过,要升级啦!");
}
@Test
public void testMethod01() {
// System.out.println("Base1Test---testMethod01 执行!");
System.out.println("大一的数学考了95分!");
}
@Test
public void testMethod02() {
// System.out.println("testMethod02 执行!");
System.out.println("大二的数学考了93分!");
}
}
package class1;
import org.junit.jupiter.api.*;
public class Base2Test extends Base1Test{
@BeforeAll
public static void beforeAll2(){
// System.out.println("Base2Test---beforeAll1 执行!");
System.out.println("我要去找宿舍的同伴!");
}
@AfterAll
public static void afterAll2(){
// System.out.println("Base2Test---afterAll 执行!");
System.out.println("我从宿舍搬出来啦!");
}
@BeforeEach
public void beforEach2(){
// System.out.println("Base2Test---BeforeEach 执行!");
System.out.println("我要熬夜奋战复习啦!");
}
@AfterEach
public void afterEach2(){
// System.out.println("Base2Test---AfterEach 执行!");
System.out.println("成绩出来了,我们去happy!");
}
@Test
public void testMethod03() {
// System.out.println("testMethod02 执行!");
System.out.println("大三的专业课考了73分!");
}
@Test
public void testMethod04() {
// System.out.println("testMethod02 执行!");
System.out.println("大四的专业课考了83分!");
}
}
https://junit.org/junit5/docs/current/user-guide/