2013-02-28 170 views
0

我已經配置我的行家和TestNG,PF低於我的pom.xml蝕:無法通過命令行從TestNG運行Maven項目...!

<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> 
    <parent> 
     <artifactId>iONAutomation</artifactId> 
     <groupId>com.iON.tcs</groupId> 
     <version>0.0.1-SNAPSHOT</version> 
    </parent> 
    <groupId>com.iON.tcs</groupId> 
    <artifactId>common</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>common</name> 
    <description>maintains all common code</description> 
    <profiles> 
     <profile> 
      <id>selenium-tests</id> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-surefire-plugin</artifactId> 
         <version>2.12.4</version> 
         <configuration> 
          <suiteXmlFiles> 
           <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> 
          </suiteXmlFiles> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 
    <dependencies> 
     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.3.1</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

</project> 

正在從CMD提示符週四runnong此目錄:d:\ EclipseWorkspace \ iON27Feb2013 \ iONAutomation \共同> 我試圖usinng mvn test和mvn -Dtest = NewTest測試命令,沒有成功。

我的CMD控制檯顯示:

D:\EclipseWorkspace\iON27Feb2013\iONAutomation\common>mvn test 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building common 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ common --- 

[debug] execute contextualize 
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, 
i.e. build is platform dependent! 
[INFO] Copying 0 resource 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ common --- 
[INFO] Nothing to compile - all classes are up to date 
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ co 
mmon --- 
[debug] execute contextualize 
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, 
i.e. build is platform dependent! 
[INFO] Copying 0 resource 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ commo 
n --- 
[INFO] Nothing to compile - all classes are up to date 
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ common --- 
[INFO] Surefire report directory: D:\EclipseWorkspace\iON27Feb2013\iONAutomation 
\common\target\surefire-reports 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 

Results : 

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

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.932s 
[INFO] Finished at: Thu Feb 28 19:11:43 IST 2013 
[INFO] Final Memory: 4M/15M 
[INFO] ------------------------------------------------------------------------ 
+0

如果您先運行: mvn clean install – 2014-07-01 14:21:20

回答

0

如果你有一個配置文件定義,那麼據我所知,你需要調用該配置文件... MVN測試-Pselenium測試。因此,如果沒有特別的理由讓你使用配置文件,那麼你可能就沒有他們,在這種情況下,mvn測試應該可以正常工作。

0

你嘗試把

<sourceDirectory>/home/{userName}/{projectLocation}/src/main/java/packageTest</sourceDirectory> 

您的構建裏面? 我有同樣的問題,這條線解決了它。

您也可以嘗試將目標添加到您的POM文件

<execution> 
     <id>default-test</id> 
     <phase>test</phase>`` 
      <goals> 
       <goal>test</goal> 
      </goals> 
     <configuration> 
     <skip>false</skip> 
     </configuration> 
</execution> 

希望它會幫助你的!