简体   繁体   English

通过pom.xml运行testng.xml,但是构建失败,尽管没有测试失败

[英]Running testng.xml via pom.xml but build getting failed although no tests fail

I'm new to automation and don't understand why my build shows failure in the console window when I execute testng.xml via pom.xml although tests execute fine. 我是自动化的testng.xml ,虽然测试执行得很好,但是当我通过pom.xml执行testng.xml时,为什么我的构建为何在控制台窗口中显示失败?

Copying my pom.xml and error which might be helpful. 复制我的pom.xml和错误可能会有所帮助。 If there is something needed, please let me know. 如果需要某些东西,请告诉我。 Your help would be highly appreciated. 您的帮助将不胜感激。

POM.xml is as below: 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>com.bookbaby.tests</groupId>
    <artifactId>CucumberTestNGMaven</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.4.0</version>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>1.2.5</version>
        </dependency>


        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>3.7.0</version>
        </dependency>

        <!-- <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.2.3</version>
        </dependency> -->
        <!-- <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency> -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
        <!-- This plugin is used to run java main class file -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <compilerVersion>1.8</compilerVersion>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <!-- This plugin is used to run java main class file -->
            <!-- <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>

                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.bookbaby.executor.RunSuite</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin> -->

    <!-- To run testNg.xml we need below plugin -->
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.20</version>
        <!-- <inherited>true</inherited> -->
        <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>testngSingle.xml</suiteXmlFile>
                </suiteXmlFiles>
                    <skipTests>false</skipTests>
                <properties>
                    <property>
                        <name>suitethreadpoolsize</name>
                        <value>3</value>
                    </property>
                </properties>
                <testFailureIgnore>false</testFailureIgnore>
          </configuration>

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

Error is below 错误如下

[INFO] Scanning for projects... [INFO]
    [INFO]------------------------------------------------------------------------ [INFO]
Building CucumberTestNGMaven 1.0-SNAPSHOT [INFO]
------------------------------------------------------------------------ [INFO]  [INFO] --- maven-resources-plugin:2.6:resources
(default-resources) @ CucumberTestNGMaven --- [INFO] Using 'UTF-8'
encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @
CucumberTestNGMaven --- [INFO] Changes detected - recompiling the
module! [INFO] Compiling 41 source files to
C:\Users\Refaque\workspace\CucumberTestNGMavenParallelRunTestng\target\classes
[INFO]  [INFO] --- maven-resources-plugin:2.6:testResources
(default-testResources) @ CucumberTestNGMaven --- [INFO] Using 'UTF-8'
encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:testCompile
(default-testCompile) @ CucumberTestNGMaven --- [INFO] Nothing to
compile - all classes are up to date [INFO]  [INFO] ---
maven-surefire-plugin:2.20:test (default-test) @ CucumberTestNGMaven
--- [INFO]  [INFO] ------------------------------------------------------- [INFO]  T E S T S [INFO] -------------------------------------------------------
[INFO] Running TestSuite doing set up in RunCukesByFeatureForFirefox
Jul 24, 2017 4:13:08 PM org.openqa.selenium.remote.ProtocolHandshake
createSession INFO: Detected dialect: OSS RemoteWebDriver: firefox on
ANY (2f84874a-05a3-48ae-8884-5ca277ff7f54) Hooks Executing
RemoteWebDriver: firefox on ANY (2f84874a-05a3-48ae-8884-5ca277ff7f54)
EXECUTING SCENARIO >>>Successfull login functionality Searching
element By.xpath: //a[@class='wisepop-close'] for presence, will wait
by 30 seconds Searching element By.xpath: //*[@id='login-link']/span
for presence, will wait by 30 seconds Searching element
By.cssSelector:
input[id="ctl00_ctl00_cphContent_cphContent_txtUserName"] for
> presence, will wait by 30 seconds Searching element By.cssSelector:
> input[id="ctl00_ctl00_cphContent_cphContent_txtPassword"] for
> presence, will wait by 30 seconds Searching element By.id:
> ctl00_ctl00_cphContent_cphContent_btnLogin for presence, will wait by
> 30 seconds Searching element By.xpath:
> //*[@id='header-menu']/div[2]/a/img for presence, will wait by 30
> seconds
> 
> 1 Scenarios ([32m1 passed[0m) 8 Steps ([32m8 passed[0m) 0m19.141s
> 
> executing after suite [INFO] Tests run: 1, Failures: 0, Errors: 0,
> Skipped: 0, Time elapsed: 56.446 s - in TestSuite [INFO]  [INFO]
> Results: [INFO]  [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped:
> 0 [INFO]  [INFO]
> ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
> ------------------------------------------------------------------------ [INFO] Total time: 01:00 min [INFO] Finished at:
> 2017-07-24T16:13:51+01:00 [INFO] Final Memory: 22M/315M [INFO]
> ------------------------------------------------------------------------ [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-surefire-plugin:2.20:test
> (default-test) on project CucumberTestNGMaven: There are test
> failures. [ERROR]  [ERROR] Please refer to
> C:\Users\Refaque\workspace\CucumberTestNGMavenParallelRunTestng\target\surefire-reports
> for the individual test results. [ERROR] Please refer to dump files
> (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and
> [date]-jvmRun[N].dumpstream. [ERROR] Error occurred in starting fork,
> check output in log [ERROR]
> org.apache.maven.surefire.booter.SurefireBooterForkException: Error
> occurred in starting fork, check output in log [ERROR] at
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:634)
> [ERROR] at
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
> [ERROR] at
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:279)
> [ERROR] at
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:243)
> [ERROR] at
> org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1077)
> [ERROR] at
> org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:907)
> [ERROR] at
> org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:785)
> [ERROR] at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
> [ERROR] at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
> [ERROR] at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
> [ERROR] at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
> [ERROR] at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
> [ERROR] at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
> [ERROR] at
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
> [ERROR] at
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
> [ERROR] at
> org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) [ERROR]
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
> [ERROR] at
> org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) [ERROR]
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) [ERROR] at
> org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) [ERROR] at
> org.apache.maven.cli.MavenCli.main(MavenCli.java:199) [ERROR] at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> [ERROR] at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> [ERROR] at java.lang.reflect.Method.invoke(Method.java:498) [ERROR] at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
> [ERROR] at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
> [ERROR] at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
> [ERROR] at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> [ERROR] -> [Help 1] [ERROR]  [ERROR] To see the full stack trace of
> the errors, re-run Maven with the -e switch. [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/MojoExecutionException`

I myself got it working by adding never although yohann.martineau 21 suggested me with "once" which didnt work but "never" worked for me. 尽管yohann.martineau 21向我建议“一次”不起作用,但“从来没有”对我有用,但我自己却通过添加从未使它起作用。 Thanks everyone. 感谢大家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM