Kaloyan Roussev
Kaloyan Roussev

Reputation: 14711

Maven test (webdriver/testng) looking for resources in non-existing folder. How can I tell it where to look for it?

I have created a selenium/webdriver testng test written in Java, using eclipse. when I am in eclipse and I have currently selected the test case .class, I can run it and it opens up a browser and runs the test. When I "mvn integration-test" it, an empty browser is opened and nothing happens. The error reads as follows

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

I really dont have such folder. I generated the maven project, using some archetype I found on the internet and I just replaced their class with mine.

Here is my folder structure:

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

this is my 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>

So my question is - how do I tell maven where to look for the test to run?

Upvotes: 1

Views: 1588

Answers (1)

Vinay
Vinay

Reputation: 754

Add a surefire plugin like the one shown below. Instead of specify your test class name

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

Upvotes: 1

Related Questions