0

我已经用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> 我尝试使用 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] ------------------------------------------------------------------------
4

2 回答 2

0

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

于 2013-03-01T17:38:59.847 回答
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>

希望它会帮助你!

于 2014-09-23T08:33:20.790 回答