Announcement Announcement Module
Collapse
No announcement yet.
Configure Failsafe for integration tests and Surefire for unit tests Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 12:28 PM.

  • #2
    I have now tried to get Cargo to start up my local Tomcat 6 and while that works there are problems. The integration test build and run, but fails even though the server starts. There seem to be some kind of deploy problem.
    If I run the server from "Server" in Eclipse the integration tests succeed, as before.

    Any suggestions are welcome!

    Here's my cargo-maven-plugin setup:
    Code:
    <plugin
    <groupId>org.codehaus.cargo</groupId>
    				<artifactId>cargo-maven2-plugin</artifactId>
    				<version>1.2.1</version>
    				<configuration>
    					<container>
    						<containerId>tomcat6x</containerId>
    						<type>installed</type>
    						<home>/Applications/Dev/apache-tomcat-6.0.35</home>				
    					</container>
    					<configuration>
    						<type>existing</type>
    						<home>/Applications/Dev/apache-tomcat-6.0.35</home>
    					</configuration>
    				</configuration>
    				<executions>
    				<execution>
    					<id>verify-deploy</id>
    					<phase>install</phase>
    					<goals>
    						<goal>deployer-deploy</goal>
    					</goals>
    				</execution>
    				<!-- before integration tests are run: start server -->
    					<execution>
    						<id>start-container</id>
    						<phase>pre-integration-test</phase>
    						<goals>
    							<goal>start</goal>
    						</goals>
    					</execution>
    					<execution>
    						<id>stop-container</id>
    						<phase>post-integration-test</phase>
    						<goals>
    							<goal>stop</goal>
    						</goals>
    					</execution>
    					<execution>
    						<id>clean-undeploy</id>
    						<phase>pre-clean</phase>
    						<goals>
    							<goal>stop</goal>
    						</goals>
    					</execution>
    				</executions>
    			</plugin>
    Last edited by MiB; May 5th, 2012, 06:22 PM.

    Comment

    Working...
    X