运行Maven Cucumber Test,我收到了以下错误没有为此版本指定目标

时间:2018-01-07 16:58:03

标签: java eclipse maven selenium 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 ,后清理,前期网站,网站,后期网站,网站部署。 - &GT; [帮助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 ,后清理,前期网站,网站,后期网站,网站部署。

请在下面找到我的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>

2 个答案:

答案 0 :(得分:0)

只需使用以下命令

运行即可
mvn verify

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

答案 1 :(得分:0)

您的pom已指定<goal>generate</goal>

从错误消息中,它似乎不是有效的goal

&#34;可用的生命周期阶段包括:验证,初始化,生成源,流程源,生成资源,流程资源,编译,流程类,生成测试源,流程测试源, generate-test-resources,process-test-resources,test-compile,process-test-classes,test,prepare-package,package,pre-integration-test,integration-test,post-integration-test,verify,install,部署,预清洁,清洁,后清理,站点前,站点,站点后,站点部署。&#34;

因此,要更具体地说明您要生成的内容:generate-sourcesgenerate-resourcesgenerate-test-sourcesgenerate-test-resources

相关问题