无法通过命令行从TestNG运行Maven项目......!

时间:2013-02-28 13:43:15

标签: maven testng

我已经使用maven和testNG配置了我的eclipse,PF下面是我的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>
    <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提示符开始运行这个目录:D:\ EclipseWorkspace \ iON27Feb2013 \ iONAutomation \ common&gt; 我尝试使用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] ------------------------------------------------------------------------

2 个答案:

答案 0 :(得分:0)

如果您定义了配置文件,那么afaik,您需要调用该配置文件... mvn test -Pselenium-tests。因此,如果您没有特别的理由使用配置文件,那么您可能只是没有它们,在这种情况下,mvn测试应该可以正常工作。

答案 1 :(得分: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>

希望它会对你有所帮助!

相关问题