我又要回到Java世界了...我正在学习教程(https://spring.io/guides/gs/spring-boot/),当我使用 运行测试时mvn test,没有任何测试HelloControllerIT正在运行。似乎只考虑以“Test”结尾的类。我确信有一种方法可以添加其他模式,以便将HelloControllerIT其包含在内。在哪里可以找到有关此主题的更多信息?这看起来很简单,所以我可能没有在搜索中使用正确的关键字(例如,'java spring boot test pattern')。更新感谢 Yug Singh 的回答,我能够想出一个我感觉很好的解决方案。我将此添加到我的pom.xml文件中,现在我可以运行与集成测试分开的单元测试。我忘记了简介...+ <profiles>+ <profile>+ <id>integration</id>+ <build>+ <plugins>+ <plugin>+ <groupId>org.apache.maven.plugins</groupId>+ <artifactId>maven-surefire-plugin</artifactId>+ <configuration>+ <includes>+ <include>**/*IT.java</include>+ </includes>+ </configuration>+ </plugin>+ </plugins>+ </build>+ </profile>+ </profiles>运行单元测试mvn test运行集成测试mvn test -Pintegration
1 回答
呼啦一阵风
TA贡献1802条经验 获得超6个赞
您可以在 pom.xml 文件中尝试以下内容:
<build>
<testSourceDirectory>src/main/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
恕我直言,您应该将测试放在测试包中,因为这是惯例。
添加回答
举报
0/150
提交
取消