2

MavenとTestNGを使用したSeleniumプロジェクトがあります。

Mavenコマンドを使用してテストを実行するためのいくつかの異なる方法を試しました(sure fireプラグインを使用しています)。Mavenを実行すると、テストが実行されません。エラーはありません。

mvn testを使用するときにテストを実行するために従うことができる良い例やチュートリアルを誰かが持っていますか?

前もって感謝します。

出力は次のとおりです。

C:\**************>mvn test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - **************:**************:jar:1.0
[INFO]    task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 4 resources
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\**************\src\test\res
ources
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Oct 02 15:14:10 BST 2012
[INFO] Final Memory: 16M/38M
[INFO] ------------------------------------------------------------------------

そして、私のPOMファイルからのsurefire構成:

<plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <encoding>iso-8859-1</encoding>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.4</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src/main/test_suites/local/***_Test.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
4

1 に答える 1

10

このMaven Using TestNGサイトを見てください。

基本的に、TestNG に依存関係を追加するだけです。

<dependencies>
  [...]
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.3.1</version>
      <scope>test</scope>
    </dependency>
  [...]
</dependencies>

デフォルトのインクルードは次のmaven-surefire-pluginとおりです。

<includes>
    <include>**/Test*.java</include>
    <include>**/*Test.java</include>
    <include>**/*TestCase.java</include>
</includes>

つまり、テスト クラスの名前が上記のインクルード パターンと一致しない場合、 はmaven-surefire-pluginそれらを見つけて実行しません。

これらをプラグイン構成に追加することで、含めるファイルを変更/追加できます。

于 2012-10-02T13:59:22.650 に答える