构建成功,但测试无法与Maven一起运行

时间:2018-10-10 16:41:22

标签: maven selenium-webdriver testng

在目标的全新安装上,我无法使用Maven运行测试,.Pom和.Jar文件已创建到.m2文件夹,但测试未运行,请有人帮助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

    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] -------- -------- [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] ----------------------------------------------- -------------------------

2 个答案:

答案 0 :(得分:0)

我看不到您pom的任何问题。只要确保您的testng.xml路径正确

<suiteXmlfiles>src/test/resources/testng.xml</suiteXmlfiles>

一种方法是将testng.xml放入pom文件所在的根文件夹,然后将pom更改为:

<suiteXmlfiles>testng.xml</suiteXmlfiles>

重新运行,看看!

答案 1 :(得分:0)

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

ValueSpliterator
相关问题