Maven测试(webdriver / testng)在不存在的文件夹中查找资源。我怎么能告诉它在哪里寻找它?

时间:2013-07-23 09:44:00

标签: maven testing webdriver

我使用eclipse创建了一个用Java编写的selenium / webdriver testng测试。 当我在eclipse中并且我当前选择了测试用例.class时,我可以运行它并打开浏览器并运行测试。 当我“集成测试”它时,打开一个空的浏览器,没有任何反应。错误如下所示

 --- 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在哪里寻找要运行的测试?

1 个答案:

答案 0 :(得分:1)

添加如下所示的surefire插件。而不是指定您的测试类名称

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