【问题标题】:Running Maven Cucumber Test, I'm getting following error No goals have been specified for this build运行 Maven Cucumber 测试,我收到以下错误没有为此构建指定目标
【发布时间】:2018-06-16 19:02:05
【问题描述】:

我在运行 Cucumber 测试时遇到以下错误,请大家帮忙解决这个问题。

您必须以<plugin-prefix>:<goal><plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal> 格式指定有效的生命周期阶段或目标。可用的生命周期阶段有:验证、初始化、生成源、流程源、生成资源、流程资源、编译、流程类、生成测试源、流程测试源、生成测试资源、流程-test-resources、test-compile、process-test-classes、test、prepare-package、package、pre-integration-test、integration-test、post-integration-test、verify、install、deploy、pre-clean、clean ,清理后,站点前,站点,站点后,站点部署。 -> [帮助 1]
org.apache.maven.lifecycle.NoGoalSpecifiedException:没有为此构建指定目标。您必须以<plugin-prefix>:<goal><plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal> 的格式指定有效的生命周期阶段或目标。可用的生命周期阶段有:验证、初始化、生成源、流程源、生成资源、流程资源、编译、流程类、生成测试源、流程测试源、生成测试资源、流程-test-resources、test-compile、process-test-classes、test、prepare-package、package、pre-integration-test、integration-test、post-integration-test、verify、install、deploy、pre-clean、clean , post-clean, pre-site, site, post-site, site-deploy。

请在下面找到我的 POM.xml

<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>MavenFrame</groupId>
  <artifactId>SampleProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>SampleProject</name>
  <url>http://maven.apache.org</url>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>1.2.5</version>
</dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
            <scope>test</scope>
        </dependency>

      <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.9.8</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>3.8.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.14.1</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>3.8.0</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>MyProjectName</projectName>  <!-- Replace with project name -->
                            <outputDirectory>target/cucumber-reports/advanced-reports</outputDirectory>
                            <cucumberOutput>target/cucumber-reports/CucumberTestReport.json</cucumberOutput>
                            <buildNumber>1</buildNumber>
                            <parallelTesting>false</parallelTesting>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
<!--   <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

【问题讨论】:

  • 分享你如何调用 Maven。您发出的确切命令是什么?

标签: java eclipse maven selenium cucumber


【解决方案1】:

只需使用以下命令运行,

mvn verify

错误将消失。您可以传递任何有效的目标,如测试、编译、测试编译等。我猜,您正在运行没有任何参数的 mvn 命令。请检查命令行语法。

【讨论】:

    【解决方案2】:

    从您的 pom 中,您指定了 &lt;goal&gt;generate&lt;/goal&gt;

    从错误信息来看,这似乎不是一个有效的goal

    “可用的生命周期阶段是:验证、初始化、生成源、流程源、生成资源、流程资源、编译、流程类、生成测试源、流程测试源、生成测试-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre -clean, clean, post-clean, pre-site, site, post-site, site-deploy。”

    所以更具体地说明您想要生成的内容:generate-sourcesgenerate-resourcesgenerate-test-sourcesgenerate-test-resources

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-04
      • 2016-04-16
      • 2017-01-09
      相关资源
      最近更新 更多