0

私はmavenとtestNGでEclipseを構成しました。以下のpom.xmlをPFします。

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

D:\EclipseWorkspace\iON27Feb2013\iONAutomation\common> mvn test および mvn -Dtest=NewTest テスト コマンドを使用してみましたが、成功しませんでした。

私のコマンドコンソールが表示されます:

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

入れてみましたか

<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 に答える
0

プロファイルが定義されている場合は、そのプロファイルを呼び出す必要があります...mvn test -Pselenium-tests. そのため、プロファイルを使用する特別な理由がない場合は、プロファイルを使用せずにそのまま使用できます。その場合、mvn テストは問題なく動作するはずです。

于 2013-03-01T17:38:59.847 に答える