执行Cucumber JVM并行插件时出现错误“由:java.lang.IllegalArgumentException和java.net.URISyntaxException:引起的”

时间:2019-02-16 19:07:07

标签: cucumber-jvm

黄瓜V. 4.2.3 |硒V.3.8.1 | JUnit V.4.12 | Cucumber-jvm-并行插件V.2.0.0 | maven-surefire-plugin V.2.19 | Maven编译器        插件v.3.3

通过Cucumber-JVM并行插件运行测试脚本时,出现错误

SELECT    t1.id, t1.req, COALESCE(t2.act, 0) AS act
FROM      tbl1 AS t1
LEFT JOIN (SELECT   id, SUM(act)
           FROM     tbl2
           GROUP BY id) t2 ON t1.id = t2.id

Surefire的实现是-

        -------------------------------------------------------
         T E S T S
        -------------------------------------------------------
        Running Parallel01IT
        Running Parallel02IT
        Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 
0.156 sec 
        <<< FAILURE! - in Parallel01IT
        initializationError(Parallel01IT)  Time elapsed: 0.014 sec  <<< 
ERROR!
        java.lang.IllegalArgumentException: D:/Learning/Eclipse Projects 
     Backup/TheTransformer(CucumberParallelExecutionWithJVMPlugin)/src/test/resou 
        rces/features/AddEditShipAddrOrdRev.feature is not valid. Try URI[:LINE]*
        Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 19: D:/Learning/Eclipse Projects Backup/TheTransformer(CucumberParallelExecutionWithJVMPlugin)/src/test/resources/features/AddEditShipAddrOrdRev.feature
        Caused by: java.net.URISyntaxException: Illegal character in path at index 19: D:/Learning/Eclipse Projects Backup/TheTransformer(CucumberParallelExecutionWithJVMPlugin)/src/test/resources/features/AddEditShipAddrOrdRev.feature

        Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.189 sec <<< FAILURE! - in Parallel02IT
        initializationError(Parallel02IT)  Time elapsed: 0.004 sec  <<< ERROR!
        java.lang.IllegalArgumentException: D:/Learning/Eclipse Projects Backup/TheTransformer(CucumberParallelExecutionWithJVMPlugin)/src/test/resources/features/LogIn.feature is not valid. Try URI[:LINE]*
        Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 19: D:/Learning/Eclipse Projects Backup/TheTransformer(CucumberParallelExecutionWithJVMPlugin)/src/test/resources/features/LogIn.feature
        Caused by: java.net.URISyntaxException: Illegal character in path at index 19: D:/Learning/Eclipse Projects Backup/TheTransformer(CucumberParallelExecutionWithJVMPlugin)/src/test/resources/features/LogIn.feature


        Results :

        Tests in error: 
          Parallel01IT.initializationError » IllegalArgument D:/Learning/Eclipse Project...
          Parallel02IT.initializationError » IllegalArgument D:/Learning/Eclipse Project...

        Tests run: 2, Failures: 0, Errors: 2, Skipped: 0

        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD FAILURE
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 8.041 s
        [INFO] Finished at: 2019-02-17T00:01:37+05:30
        [INFO] ------------------------------------------------------------------------
        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test (default-test) on project CaptainJackSparrow: There are test failures.
        [ERROR] 
        [ERROR] Please refer to D:\Learning\Eclipse Projects Backup\TheTransformer(CucumberParallelExecutionWithJVMPlugin)\target\surefire-reports for the individual test results.
        [ERROR] -> [Help 1]
        org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test (default-test) on project CaptainJackSparrow: There are test failures.

        Please refer to D:\Learning\Eclipse Projects Backup\TheTransformer(CucumberParallelExecutionWithJVMPlugin)\target\surefire-reports for the individual test results.
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
            at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
            at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
            at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
            at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
            at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
        Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

        Please refer to D:\Learning\Eclipse Projects Backup\TheTransformer(CucumberParallelExecutionWithJVMPlugin)\target\surefire-reports for the individual test results.
            at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:91)
            at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:318)
            at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:880)
            at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:739)
            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
            ... 20 more
        [ERROR] 
        [ERROR] Re-run Maven using the -X switch to enable full debug logging.
        [ERROR] 
        [ERROR] For more information about the errors and possible solutions, please read the following articles:
        [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

并且Maven编译器插件配置为-

        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19</version>
                <configuration>
                    <forkCount>5</forkCount>
                    <reuserForks>true</reuserForks>

                    <includes>
                        <include>**/Parallel*IT.class</include>
                    </includes>
                </configuration>
            </plugin>

黄瓜jvm并行插件配置以创建运行时运行程序

        <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin> 

登录功能文件为

功能:以注册用户身份登录

    <plugin>
            <groupId>com.github.temyers</groupId>
            <artifactId>cucumber-jvm-parallel-plugin</artifactId>
            <version>2.0.0</version>
            <executions>
                <execution>
                    <id>generateRunners</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>generateRunners</goal>
                    </goals>
                    <configuration>
                        <glue>com.ann.automation.test.steps</glue>


    <featuresDirectory>src/test/resources/features/</featuresDirectory>
                            <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>

                        <format>json,html</format>
                        <tags>"@fp"</tags>
                    </configuration>
                </execution>
            </executions>
        </plugin>

第二个功能文件是-

功能:以注册用户的身份添加(添加/编辑)运输

 @fp
  Scenario: Log into the Site as Registered User
    Given User is on Brand Home Page "https://factory.anntaylor.com"
    When User clicks on the Sign In link, She lands on the Sign In Page
    And User choose to enter Email ID & Password of the registered account, She lands on the My Account Page

RunCuke文件为-

  @fp
  Scenario: Add/Edit Shipping Address from Order Review Page as Reg User
    Given User is on Brand Home Page "https://factory.anntaylor.com"
    When User clicks on Super & Sub Category from Mega Menu, She lands on the PLP Page
    And User selects a product on PLP & SKU on PDP
    And User moves to Shopping Bag and choose to log into site as Registered User
    Then Verify User shall land on Order Review Page
    And User choose to Add New Shipping Add clicking on Add New Button
    Then Verify New Shipping Address reflects on Order Review Page
    And User choose to Edit Shipping Add clicking on Edit Button
    Then Verify Updated Shipping Add on Order Review Page       

POM.xml配置为

            package com.ann.automation.runner;

            import org.junit.runner.RunWith;
            import cucumber.api.CucumberOptions;
            import cucumber.api.junit.Cucumber;

            @RunWith(Cucumber.class)
            @CucumberOptions(features = "classpath:features/",
                                 glue = {"com.ann.automation.test.steps" },
                                 tags = { "@fp" },
                               plugin = { "pretty","json:target/cucumber-json/cucumber.json",
                                          "junit:target/cucumber-reports/Cucumber.xml", "html:target/cucumber-reports"},
                               strict = false,
                               dryRun = false,
                           monochrome = true)

            public class RunCuke {  

            }

有人可以告诉我为什么我遇到此错误

                <properties>
                    <project.build.sourceEncoding>UTF-

            8</project.build.sourceEncoding>

                    <selenium.version>3.8.1</selenium.version>
                </properties>

                <dependencies>

                <dependency>
                    <groupId>io.cucumber</groupId>
                    <artifactId>cucumber-java</artifactId>
                    <version>4.2.3</version>
                </dependency>

                <dependency>
                    <groupId>io.cucumber</groupId>
                    <artifactId>cucumber-junit</artifactId>
                    <version>4.2.3</version>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>4.12</version>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>io.cucumber</groupId>
                    <artifactId>datatable</artifactId>
                    <version>1.1.12</version>
                </dependency>

                <!-- <dependency>
                    <groupId>io.cucumber</groupId>
                    <artifactId>cucumber-testng</artifactId>
                    <version>4.2.3</version>
                </dependency>  -->

                <dependency>
                    <groupId>io.cucumber</groupId>
                    <artifactId>cucumber-picocontainer</artifactId>
                    <version>4.2.3</version>
                    <scope>test</scope>
                </dependency>

                    <dependency>
                        <groupId>com.google.code.gson</groupId>
                        <artifactId>gson</artifactId>
                        <version>2.8.2</version>
                    </dependency>

                    <dependency>
                        <groupId>net.masterthought</groupId>
                        <artifactId>cucumber-sandwich</artifactId>
                        <version>0.0.4</version>
                    </dependency>

                    <dependency>
                        <groupId>javax.mail</groupId>
                        <artifactId>javax.mail-api</artifactId>
                        <version>1.5.5</version>
                    </dependency>

                    <dependency>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                        <version>1.2.17</version>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.poi</groupId>
                        <artifactId>poi</artifactId>
                        <version>3.11-beta3</version>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.poi</groupId>
                        <artifactId>poi-ooxml</artifactId>
                        <version>3.9</version>
                    </dependency>

                    <dependency>
                        <groupId>xml-apis</groupId>
                        <artifactId>xml-apis</artifactId>
                        <version>2.0.2</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hamcrest</groupId>
                        <artifactId>hamcrest-all</artifactId>
                        <version>1.3</version>
                    </dependency>

                    <dependency>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-java</artifactId>
                        <version>${selenium.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>com.vimalselvam</groupId>
                        <artifactId>cucumber-extentsreport</artifactId>
                        <version>3.1.1</version>
                    </dependency>

                    <dependency>
                        <groupId>com.aventstack</groupId>
                        <artifactId>extentreports</artifactId>
                        <version>3.1.1</version>
                    </dependency>

                    <dependency>
                        <groupId>commons-io</groupId>
                        <artifactId>commons-io</artifactId>
                        <version>2.6</version>
                    </dependency>

                    <dependency>
                        <groupId>io.appium</groupId>
                        <artifactId>java-client</artifactId>
                        <version>3.4.0</version>
                    </dependency>

                    <dependency>
                        <groupId>com.itextpdf</groupId>
                        <artifactId>itextpdf</artifactId>
                        <version>5.4.0</version>
                    </dependency>

                    <dependency>
                        <groupId>com.lowagie</groupId>
                        <artifactId>itext</artifactId>
                        <version>1.3.1</version>
                    </dependency>

                    <dependency>
                        <groupId>com.codeborne</groupId>
                        <artifactId>phantomjsdriver</artifactId>
                        <version>1.2.1</version>
                    </dependency>

                    <dependency>
                        <groupId>io.github.bonigarcia</groupId>
                        <artifactId>webdrivermanager</artifactId>
                        <version>3.0.0</version>
                    </dependency>

                    <dependency>
                        <groupId>com.CA.ATU21</groupId>
                        <artifactId>ATUTestRecorder</artifactId>
                        <version>2.1</version>
                    </dependency>

                    <dependency>
                        <groupId>com.googlecode.json-simple</groupId>
                        <artifactId>json-simple</artifactId>
                        <version>1.1.1</version>
                    </dependency>

                </dependencies>

                <build>
              <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->

                    <pluginManagement>
                        <plugins>
                            <plugin>
                                <groupId>org.eclipse.m2e</groupId>
                                <artifactId>lifecycle-mapping</artifactId>
                                <version>1.0.0</version>
                                <configuration>
                                    <lifecycleMappingMetadata>
                                        <pluginExecutions>
                                            <pluginExecution>
                                                <pluginExecutionFilter>


            <groupId>com.github.temyers</groupId>
                                                        <artifactId>cucumber-jvm-parallel-plugin</artifactId>
                                                        <versionRange>[2.0.0,)</versionRange>

                                                    <goals>
                                                        <goal>generateRunners</goal>
                                                    </goals>
                                                </pluginExecutionFilter>
                                                <action>
                                                    <ignore />
                                                </action>
                                            </pluginExecution>
                                            <pluginExecution>
                                                <pluginExecutionFilter>
                                                    <groupId>
                                                        org.apache.maven.plugins
                                                    </groupId>
                                                    <artifactId>
                                                        maven-compiler-plugin
                                                    </artifactId>
                                                    <versionRange>
                                                        [3.3,)
                                                    </versionRange>
                                                    <goals>
                                                        <goal>testCompile</goal>
                                                    </goals>
                                                </pluginExecutionFilter>
                                                <action>
                                                    <ignore></ignore>
                                                </action>
                                            </pluginExecution>
                                        </pluginExecutions>
                                    </lifecycleMappingMetadata>
                                </configuration>
                            </plugin>
                        </plugins>
                    </pluginManagement>
                    <plugins>

                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.19</version>
                    <configuration>
                        <forkCount>5</forkCount>
                        <reuserForks>true</reuserForks>

                        <includes>
                            <include>**/Parallel*IT.class</include>
                        </includes>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>com.github.temyers</groupId>
                    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
                    <version>2.0.0</version>
                    <executions>
                        <execution>
                            <id>generateRunners</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>generateRunners</goal>
                            </goals>
                            <configuration>
                                <glue>com.ann.automation.test.steps</glue>


            <featuresDirectory>src/test/resources/features/</featuresDirectory>
                                    <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>

                                <format>json,html</format>
                                <tags>"@fp"</tags>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

              </plugins>
            </build>
            </project>  

另外,我不确定,是否必须使用maven编译器插件?如果是这样,那么有人可以告诉我Cucumber-jvm并行插件,surefire插件和编译器插件的版本依赖性是什么

0 个答案:

没有答案