【发布时间】:2021-12-09 15:18:35
【问题描述】:
我正在使用 junit4 运行测试。我的测试类如下 test->java->com.example->ProductIT.java 当我在我的项目上运行 mvn clean install 时,无法识别以下测试并且无法运行。 但是,当我将测试类重命名为 ProductTest 时,它可以工作。 我不明白其中的区别。为什么我重命名时它会起作用?
@ContextConfiguration(locations = {"classpath:META-INF/spring/test-config.xml"})
@RunWith(SpringJunit4ClassRunner.class)
public class ProductIT{
@Autowried
private ProductServiceImpl serviceImpl;
@Test
public void test() throws Exception{
assertNotNull(serviceImpl)
}
}
pom.xml
<dependencyManagement>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core></artifactId>
<version>4.2.4-RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-infrastructure></artifactId>
<version>4.2.4-RELEASE</version>
</dependency>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch></artifactId>
<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter></artifactId>
<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test></artifactId>
<scope>test</scope>
<dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
【问题讨论】:
标签: spring-boot junit integration-testing spring-test