构建成功,但测试无法与Maven一起运行 [英] Build is Success but Test does not run with Maven

查看:94
本文介绍了构建成功,但测试无法与Maven一起运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在目标的全新安装上,我无法使用Maven运行我的测试,.Pom和.Jar文件已创建到.m2文件夹,但该测试未运行,请有人帮助TIA.

I'm Unable to run My test using Maven, on Clean Install from goals, .Pom and .Jar files are created to the .m2 folder, but the test is not running, can someone please help TIA.

  1. TestNG文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
  <test thread-count="5" name="Test">
    <classes>
      <class name="Project_Pkg_Mvn.NewTest1" />
    </classes>
  </test>
  <!-- Test -->
</suite>
<!-- Suite -->

  1. Pom.xml

  1. Pom.xml

http://maven.apache.org/xsd/maven-4.0.0.xsd> 4.0.0 Project_Maven_Group_Test Project_Maven_Artifact_Test 0.0.1-SNAPSHOT

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 Project_Maven_Group_Test Project_Maven_Artifact_Test 0.0.1-SNAPSHOT

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


<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.14.0</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.jexcelapi</groupId>
        <artifactId>jxl</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>

</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <fork>true</fork>
                <executable>C:\Program Files\Java\jdk1.8.0_121\bin\javac.exe</executable>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <suiteXmlfiles>src/test/resources/testng.xml</suiteXmlfiles>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

控制台输出

[INFO]扫描项目... [警告] [警告]为Project_Maven_Group_Test构建有效模型时遇到了一些问题:Project_Maven_Artifact_Test:jar:0.0.1-SNAPSHOT [警告]'build.plugins.plugin.(groupId:artifactId)'必须是唯一的,但发现插件org.apache.maven.plugins:maven-compiler-plugin的重复声明@第50行,第12列 [警告] [警告]强烈建议修复这些问题,因为它们会威胁到您的构建的稳定性. [警告] [警告]因此,将来的Maven版本可能不再支持构建此类格式错误的项目. [警告] [信息] [INFO] --------< Project_Maven_Group_Test:Project_Maven_Artifact_Test> -------- [INFO]建立Project_Maven_Artifact_Test 0.0.1-SNAPSHOT [INFO] -------------------------------- [jar] ------------ --------------------- [警告]工件org.apache.commons:commons-io:jar:1.3.2已重定位到commons-io:commons-io:jar:1.3.2 [信息] [INFO] --- maven-resources-plugin:2.6:resources(默认资源)@ Project_Maven_Artifact_Test- [INFO]使用'UTF-8'编码复制过滤的资源. [INFO]正在复制0个资源 [信息] [INFO] --- maven-compiler-plugin:3.5.1:compile(默认编译)@ Project_Maven_Artifact_Test- [INFO]无需编译-所有类都是最新的 [信息] [INFO] --- maven-resources-plugin:2.6:testResources(default-testResources)@ Project_Maven_Artifact_Test- [INFO]使用'UTF-8'编码复制过滤的资源. [INFO]正在复制1个资源 [信息] [INFO] --- maven-compiler-plugin:3.5.1:testCompile(default-testCompile)@ Project_Maven_Artifact_Test- [INFO]无需编译-所有类都是最新的 [信息] [INFO] --- maven-surefire-plugin:2.22.0:test(默认测试)@ Project_Maven_Artifact_Test- [INFO] ----------------------------------------------- ------------------------- [INFO]建立成功 [INFO] ----------------------------------------------- ------------------------- [INFO]总时间:1.701 s [INFO]结束于:2018-10-10T21:58:30 + 05:30 [INFO] ----------------------------------------------- -------------------------

[INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for Project_Maven_Group_Test:Project_Maven_Artifact_Test:jar:0.0.1-SNAPSHOT [WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-compiler-plugin @ line 50, column 12 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] --------< Project_Maven_Group_Test:Project_Maven_Artifact_Test >-------- [INFO] Building Project_Maven_Artifact_Test 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2 [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Project_Maven_Artifact_Test --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ Project_Maven_Artifact_Test --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Project_Maven_Artifact_Test --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ Project_Maven_Artifact_Test --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.22.0:test (default-test) @ Project_Maven_Artifact_Test --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.701 s [INFO] Finished at: 2018-10-10T21:58:30+05:30 [INFO] ------------------------------------------------------------------------

推荐答案

好的,您可以使用此pom文件将pom从属性替换到末尾吗(其中有一些不需要的额外依赖项)我只想看看surefire和jdk是否可以解决问题)

ok can you replace you pom from properties to the end with this pom file (there are some extra dependecies in it that you dont need ) I just want to see if the surefire and the jdk can fix the problem )

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <!-- Below plug-in is used to execute tests -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <testFailureIgnore>true</testFailureIgnore>
                <suiteXmlFiles>
                    <!-- TestNG suite XML files -->
                    <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.aeonbits.owner</groupId>
        <artifactId>owner</artifactId>
        <version>1.0.8</version>
    </dependency>

    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>3.0.7</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.mail/javax.mail-api -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>javax.mail-api</artifactId>
        <version>1.5.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.5</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.2</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.4</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.11.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.11.0</version>
    </dependency>
    <dependency>
        <groupId>ru.yandex.qatools.ashot</groupId>
        <artifactId>ashot</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>com.relevantcodes</groupId>
        <artifactId>extentreports</artifactId>
        <version>2.41.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
    <dependency>
        <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.23</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.8.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.mongodb/mongodb-driver -->
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongodb-driver</artifactId>
        <version>3.0.4</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.8.11.1</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.17</version>
    </dependency>       
     <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>3.17</version>
    </dependency>        
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.17</version>
    </dependency>

    <dependency>
        <groupId>com.vimalselvam</groupId>
        <artifactId>testng-extentsreport</artifactId>
        <version>1.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.codeborne</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>1.2.1</version>
    </dependency>


</dependencies>

这篇关于构建成功,但测试无法与Maven一起运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆