java - mvn test 不运行任何测试(JUnit 4 或 JUnit 5)
问题描述
我知道你一开始会怎么想:“你应该用'Test'来命名你的测试类等等。” 但问题是:情况已经如此。我确实滚动了所有可能的 SO 帖子,但没有找到任何东西,所以不,不幸的是,这不是重复的。
我什至有一个名为 TestPleaseWillYouRunMyTest 的测试类和一个名为 testPleaseTest() 的测试方法。
当我运行“mvn test”时,“target/test-classes”文件夹填充得很好,所以我真的不明白为什么我的测试没有运行......
以防万一它有助于理解问题,这是我的 pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>SeleniumTests</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
</configuration>
</plugin>
</plugins>
<testSourceDirectory> src/test/java </testSourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
</dependencies>
</project>
解决方案
为什么要添加 testng、junit 4 和 5?首先决定你要使用哪个测试框架
推荐阅读
- python - 如何使用 pandas python 或 excel 替换特定数据
- python - 火炬 | 得到“RuntimeError: Found dtype Long but expected Float”
- java - Vaadin 是否具有相当于 JavaFX GridPane 的功能?
- python - Gstreamer 时间戳错误值,缓冲区没有偏移或持续时间
- javascript - ChartJS 悬停/工具提示:根据 x 值在数据集中选择正确的点
- bash - 无法使变量脱离循环
- telegram - 为什么具有管理员权限的电报机器人无法提升群组成员?
- python - 循环和压缩字典和列表到一个新的列表字典
- python - 为什么 Pydantic 不验证字段分配?
- asp.net-core-3.1 - 为 ASP.NET Core 响应正文添加前缀文本