我有一个使用Spring和Junit 5的简单应用程序:
当使用Spring 2.1 (例如,2.1.8或2.1.12)时,我的单元测试运行平稳
当使用SpringBoot2.2(例如,2.2.2.RELEASE或2.3.2.RELEASE)时,我的单元测试失败并出现错误消息
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project XXX: There are test failures.
[ERROR]
我有以下几点:
public class EnvWebEndpointExtensionEnvironmentPostProcessorTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Rule
public MockitoRule rule = MockitoJUnit.rule();
final EnvWebEndpointExtensionEnvironmentPostProcessor postProcessor = new EnvWebEndpointExten
我正在尝试测试存储库。遗憾的是,当我尝试测试时,我总是得到相同的错误。错误如下:
java.lang.NullPointerException
at com.changing.springboot.repository.TemplateRepositoryTest.should_return_templateName_when_call_findByTemplateName(TemplateRepositoryTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at s
我已经创建了一个springboot项目,分为三个maven模块,域层、核心层(包含持久性和业务逻辑)和web层。我尝试单元测试我的存储库ProductRepository (位于核心层)。
@RunWith(SpringRunner.class) // provide bridge between SpringBoot test features and JUnit, for usage of springboot tsting features
@DataJpaTest
class ProductRepositoryTest {
@Autowired
private TestEnt
在本地运行某些@WebMvcTest时,我没有问题(SpringBoot1.5.8,gradle 4.6):
@RunWith(SpringRunner.class)
@WebMvcTest(VZNFCController.class)
public class VZNFCControllerTest {
private VZNFCTagAction action1 = new VZNFCTagAction();
private VZNFCTagAction action2 = new VZNFCTagAction();
@Before
public void setUp(