1

我使用 eclipse 创建了一个用 Java 编写的 selenium/webdriver testng 测试。当我在eclipse中并且我当前选择了测试用例.class时,我可以运行它,它会打开一个浏览器并运行测试。当我“mvn integration-test”它时,会打开一个空的浏览器并且什么也没有发生。错误内容如下

 --- maven-resources-plugin:2.6:resources (default-resources) @ functionalTests ---
 Using 'UTF-8' encoding to copy filtered resources.
 skip non existing resourceDirectory c:\test2\functionalTests\src\main\resources

 --- maven-compiler-plugin:2.5.1:compile (default-compile) @ functionalTests ---
 Nothing to compile - all classes are up to date

 --- maven-resources-plugin:2.6:testResources (default-testResources) @ functionalTests ---
 Using 'UTF-8' encoding to copy filtered resources.
 skip non existing resourceDirectory c:\test2\functionalTests\src\test\resources

我真的没有这样的文件夹。我使用我在互联网上找到的一些原型生成了 maven 项目,我只是用我的类替换了他们的类。

这是我的文件夹结构:

src
-main
--java
---com
----pragmaticqa
-----tests
test
-java
--com
---pragmaticqa
----tests
and inside tests is where my test .class is located.

这是我的 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>

  <groupId>com.pragmaticqa.tests</groupId>
  <artifactId>functionalTests</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>functionalTests</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>2.32.0</version>
    </dependency>  
    <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>6.8</version>
          <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.sf.opencsv</groupId>
        <artifactId>opencsv</artifactId>
        <version>2.0</version>
    </dependency>
  </dependencies>
  <build>
  <plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>selenium-maven-plugin</artifactId>
        <version>2.3</version>
        <executions>
            <execution>
                <id>xvfb</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>xvfb</goal>
                </goals>
            </execution>
            <execution>
                <id>selenium</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>start-server</goal>
                </goals>
                <configuration>
                    <background>true</background>
                </configuration>
            </execution>
        </executions>
    </plugin>
   </plugins>
   </build>
</project>

所以我的问题是 - 我如何告诉 maven 在哪里寻找要运行的测试?

4

1 回答 1

1

添加一个如下图所示的万能插件。而不是指定您的测试类名称

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.5</version>
        <configuration>
               <includes>
                  <include>**/*IntegrationTest.java</include>
               </includes>
        </configuration>
</plugin>
于 2013-07-23T09:59:32.783 回答