Results 1 to 2 of 2

Thread: Configure Failsafe for integration tests and Surefire for unit tests

Threaded View

  1. #1
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default Configure Failsafe for integration tests and Surefire for unit tests

    I'm using Selenium Web driver for end to end integration testing and I have 1) refactored my integration tests to a new source folder hierarchy "src/it", 2) set up Failsafe for handling integration tests, 3) installed maven-builder-helper and finally I tried to configure surefire to ignore tests in the integration-test source folder. The latter as the name pattern of the tests didn't seem to be enough for excluding them.

    I'm having the problem that all tests run when I build, either automatically via Infinitest or when I use the menu command "Run As Junit test". It would seem the latter runs all tests no matter where. I guess it isn't issuing "mvn test". So why not use the actual maven commands instead?

    Ok, so I try mvn test from the menu which succeeds as integration tests does not run my 2 integration tests named "HomeIT.java" and "EntoIntegrationTest.java". That is until Infinitest kicks in again and run them all. So I try with "infinitest.filters" in the root of the project with these patterns:
    Code:
    **/*IT.*
    **/*IntegrationTest.*
    This seems to be working as the integration tests doesn't run now. Yay!

    Now, when I try to run the integration-test goal failsafe runs, but the previously succeeding tests fails. Obviously the server isn't started in process and the already running instance via "Server" isn't called. How can I make the start up of a tomcat instance a part of my integration tests? Perhaps use Jetty instead?

    tomcat:run doesn't run the integration tests. I must study goals better I suppose. Any pointers?

    Here's my setup of Maven Failsafe:
    Code:
    <plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-failsafe-plugin</artifactId>
    				<version>2.12</version>
    				<configuration>
    					<junitArtifactName>
    						org.junit:com.springsource.org.junit
    					</junitArtifactName>
    				</configuration>
    				<executions>
    					<execution>
    						<id>integration-test</id>
    						<goals>
    							<goal>integration-test</goal>
    						</goals>
    					</execution>
    					<execution>
    						<id>verify</id> 
    						<goals>
    							<goal>verify</goal>
    						</goals>
    					</execution>
    				</executions>
    			</plugin>
    And this is the Surefire exclusion:
    Code:
    <exclude>**/it/*</exclude>
    and finally the Maven-Builder-Helper:
    Code:
    <plugin>
    				<groupId>org.codehaus.mojo</groupId>
    				<artifactId>build-helper-maven-plugin</artifactId>
    				<version>1.5</version>
    				<executions>
    					<execution>
    						<id>add-it-source</id>
    						<goals>
    							<goal>add-test-source</goal>
    						</goals>
    						<configuration>
    							<sources>
    								<source>src/it/java</source>
    							</sources>
    						</configuration>
    					</execution>
    					<execution>
    						<id>add-it-resource</id>
    						<goals>
    							<goal>add-test-resource</goal>
    						</goals>
    						<configuration>
    							<resources>
    								<resource>
    									<directory>src/it/resources</directory>
    								</resource>
    							</resources>
    						</configuration>
    					</execution>
    				</executions>
    			</plugin>
    Last edited by MiB; May 3rd, 2012 at 11:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •