SpringBoot2.6+单元测试
SpringBoot老版本引入单元测试
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
....
@SpringBootTest
@RunWith(SpringRunner.class)
public class xxx{
@Before
public void setUp() throws Exception{
...
}
}
SpringBoot升级后引入单元测试
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;
....
@SpringBootTest
@ExtendWith(SpringExtension.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class xxx{
@BeforeAll
public void setUp() throws Exception{
...
}
}
pom.xml配置文件不变
我的笔记