无法在maven +黄瓜中运行测试

时间:2020-03-22 19:31:12

标签: java eclipse maven cucumber

使用maven运行我的黄瓜测试时,我获得了构建成功,但是没有一个测试在运行。我附上了:

  • POM依赖版本
  • 结果
  • 项目的结构
  • 亚军班

我遵循以下解决方法:

  1. 已经检查了依赖猜测的版本兼容性,这很好
  2. 删除M2存储库并重新构建项目
  3. 尝试更改项目结构并添加了命名约定 使用Java文件进行“测试”。

    T E S T S
[INFO] -------------------------------------------------------
[INFO] Running cucumberOptions.TestRunnerTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.026 s - in cucumberOptions.TestRunnerTest
[INFO] Running pages.baseTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in pages.baseTest
[INFO] Running pages.GenericUtilsTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in pages.GenericUtilsTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

POM.xml

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.7.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>gherkin</artifactId>
    <version>2.12.2</version>

</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.6</version>
</dependency>
</dependencies> 
<build>
    <!-- To define the plugin version in your parent POM -->

      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
        </plugin>
        <plugin> 
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0-M4</version>
          <configuration>

          </configuration>
        </plugin>
      </plugins>
[updated structure and result][2]

[updated structure][1]
  [1]: https://i.stack.imgur.com/t4Y79.jpg
  [2]: https://i.stack.imgur.com/3fqsL.jpg

1 个答案:

答案 0 :(得分:0)

您的项目结构未遵循Maven约定。所有测试类(以oSheet结尾)应该位于.java下,测试资源(以src/test/java结尾)应该位于.feature下。

因为您的功能文件不在正确的位置,所以Cucumber不会提取它们。

https://maven.apache.org/guides/getting-started/

您可能还需要遵循10分钟的Cucumber教程,以便在添加Selenium之前拥有一个正常的Cucumber项目。

https://cucumber.io/docs/guides/10-minute-tutorial/