【发布时间】:2021-11-10 13:51:47
【问题描述】:
我有黄瓜框架和以下pom
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>CucumberE2ETest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
运行测试后,我得到了这个
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
如您所见,测试运行为 0。 测试从 IntelliJ 运行良好,但 maven 不运行测试。 对于大量复制粘贴的内容,我深表歉意,但我想提供尽可能多的信息,因为我不确定下一步该尝试什么。
【问题讨论】:
-
你的测试是怎么命名的?
-
嗨@ArthurKlezovich,我花了一天时间研究这个问题。我看到命名可能是个问题。由于我使用的是 Cucumber(Gherkin) 框架,它们的格式为 Scenario:XXXX、Given:XXXX、When:XXXXX、Then:XXXX,它们背后的定义是方法 public void testXXXXXX()。我认为问题出在依赖项上,很可能是 junit-jupiter,因为在引入这种依赖项之前测试已经运行。我不再使用它(我想是的),但是我得到了构建错误,当我删除它并运行“man clean install”时,我得到了构建错误。
-
上传你的代码到github并把链接留在这里