2017-05-09 4 views
0

私はtestng1.xmlをpom.xmlファイルに設定しましたが、testng1.xmlファイルで設定されているものだけでなく、@Testアノテーションを持つすべてのテストを実行しているようです。 Googleから多くの例をコピーしましたが、何も動作しません。Mavanからtestng.xmlを実行するには?

をご利用ください。ここで

は私testng1.xmlです:ここでは

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
<suite guice-stage="DEVELOPMENT" name="GroupXdefault suite"> 
    <test verbose="2" name="Default test"> 
    <classes> 
     <class name="GroupX.ArtifactX.Test2"/> 
     <class name="GroupX.ArtifactX.Test3"/> 
    </classes> 
    </test> <!-- Default test --> 
</suite> <!-- Default suite --> 

は私の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>GroupX</groupId> 
    <artifactId>ArtifactX</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 
    <name>ArtifactX</name> 
    <url>http://maven.apache.org</url> 

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

<profiles> 
    <profile> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>2.20</version> 
        <configuration> 
         <suiteXmlFiles> 
          <suiteXmlFile>testng1.xml</suiteXmlFile> 
         </suiteXmlFiles> 
        </configuration> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 
</profiles> 

    <dependencies> 

    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin --> 
    <dependency> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.20</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/org.testng/testng --> 
    <dependency> 
     <groupId>org.testng</groupId> 
     <artifactId>testng</artifactId> 
     <version>6.11</version> 
    </dependency> 



    </dependencies> 
</project> 
+0

[Mavenはmy testng.xmlを実行しません](http://stackoverflow.com/questions/43891582/maven-doesnt-run-my-testng-xml) – juherr

答えて

0

あなたのプロファイル設定(IDが欠落していると、プロファイルが有効化されていない)間違っています。ちょうど<build>セクションを<project>に移動してください。

関連する問題