I made the recommended changes.
directory structure
src / test / java - unit tests
src / it / java - integration testing

and I'm using the plugin "maven-failsafe-plugin" for integration tests.

Now the tests are run at different phases.
This is the execution order:
1. runs the unit tests
2. start selenium
3. start cargo
4. runs the integration tests
6. stop selenium
7. stop cargo
8. run the plugin "cobertura-maven-plugin"
9. run the unit tests again
10. makes the coverage of unit tests.
11. and ends

Still not doing the coverage of integration tests.

pom.xml in annex.

Thanks for your help.


2011/2/18 Shay Thompson <[email protected]>

>
> Standard testing, which uses the surefire plugin and is done at the test
> lifecycle, use the naming convention like this:
>    * "**/Test*.java" - includes all of its subdirectories and all java
> filenames that start with "Test".
>    * "**/*Test.java" - includes all of its subdirectories and all java
> filenames that end with "Test".
>    * "**/*TestCase.java" - includes all of its subdirectories and all java
> filenames that end with "TestCase".
>
> Integration-testing using the maven-failsafe-plugin use the naming
> convention like this:
>    * "**/IT*.java" - includes all of its subdirectory and all java
> filenames that start with "IT".
>    * "**/*IT.java" - includes all of its subdirectory and all java
> filenames that end with "IT".
>    * "**/*ITCase.java" - includes all of its subdirectory and all java
> filenames that end with "ITCase".
>
> So you can put everything in src/test/java and then split them up by name
> and I suggest package to keep things clean.
>
>
> -----Original Message-----
> From: Ewerton Vale Leal [mailto:[email protected]]
> Sent: Friday, February 18, 2011 6:43 PM
> To: Maven Users List
> Subject: Re: Help to use plugin coverage
>
> How do I create another directory for integration testing in maven?
>
> 2011/2/18 Shay Thompson <[email protected]>
>
> >
> > You might also want to look into the maven-failsafe-plugin for your
> > integration tests.
> >
> > -----Original Message-----
> > From: Hilco Wijbenga [mailto:[email protected]]
> > Sent: Friday, February 18, 2011 3:34 PM
> > To: Ewerton Vale Leal
> > Cc: Maven Users List
> > Subject: Re: Help to use plugin coverage
> >
> > On 18 February 2011 12:45, Ewerton Vale Leal <[email protected]>
> wrote:
> > > My directory structure is this:
> > > src/main/java
> > > src/main/resources
> > > src/main/webapp
> > > src/test/java/unitTest
> > > src/test/java/functionalTest
> >
> > This is unusual. I would suggest src/test/java for your unit tests and
> > something else (src/test/it ?) for your integration/functional tests.
> > That way at least your unit tests should run.
> >
> > You need to check out the Maven Surefire Plugin. For your integration
> > tests, you'll have to change the testSourceDirectory.
> >
> > > I have  unit tests and integration tests in the same project.
> >
> > FYI, normally, you would put the integration tests in a separate
> > project that depends on the project it's testing. I would still
> > recommend that but I don't know how you would get Cobertura working in
> > that scenario.
> >
> > > I running the commands mvn install.
> >
> > That's fine. The "verify" phase in the Maven Build Cycle is the one
> > just before "install". While you're trying things out it's a tiny bit
> > faster. :-)
> >
> > > "Why are you using <skip>true<skip>? Isn't the whole point to
> > > run the tests?"
> > > I do not know right to use maven. I'm new at this.
> > > In the configuration it has "<skip>false</skip> " and not true.
> > > If true, the tests not execute.
> >
> > I would remove <skip>.
> >
> > > To run the tests, I use a test suite, the class "AllTeste.java",
> > > running the unit tests and integration.
> >
> > You mean you're running your unit tests and integration tests all at
> > the same time? I don't think that's what you want. Also test suites
> > are not run by Surefire. It uses a pattern to identify tests. See the
> > Maven Surefire Plugin documentation.
> >
> > Run your unit tests first in phase "test" (that should not require any
> > setup as long as you've named your tests appropriately), then run your
> > integration tests in phase "integration-test". You should be able to
> > set up Surefire to run in different phases with a different
> > testSourceDirectory.
> >
> > I think you're pretty close.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
>
> --
> Ewerton Leal Vale
> Bacharelando em Ciência da Computação - UFPI
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Ewerton Leal Vale
Bacharelando em Ciência da Computação - UFPI
<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>br.ufpi</groupId>
	<artifactId>capriovi</artifactId>
	<packaging>war</packaging>
	<name>Capriovi</name>
	<version>1.0</version>

	<properties>
		<!-- <project.build.sourceEncoding>iso-8859-1</project.build.sourceEncoding> -->
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<description>Sistema de Controle Zootécnico de Rebanhos de Caprinos e
		Ovinos</description>

	<url>http://sistemaseasii.ufpi.br/capriovi</url>
	<ciManagement>
		<system>Hudson</system>
		<url>http://sistemaseasii.ufpi.br/hudson</url>
	</ciManagement>
	<organization>
		<name>UFPI - Universidade Federal do Piauí</name>
		<url>http://www.ufpi.br/</url>
	</organization>

	<developers>
		<developer>
			<name>Éwerton Leal Vale</name>
			<email>[email protected]</email>
			<organization>Lab Engenharia de Software e Informática Industrial</organization>
			<organizationUrl>http://sistemaseasii.ufpi.br</organizationUrl>
		</developer>
	</developers>

	<build>
		<finalName>${project.artifactId}</finalName>
		<testSourceDirectory>src/in</testSourceDirectory>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.5</version>
				<executions>
					<execution>
						<id>add-test-source</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-test-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>src/it/java</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.6</version>
				<executions>
					<execution>
						<id>compile</id>
						<phase>compile</phase>
						<configuration>
							<target name="Generate">
								<property name="template.folder" location="templates/template" />
								<property name="web.folder" location="src/main/webapp" />

								<echo>jHeat: Deleting the previous generated application...
								</echo>
								<delete dir="${web.folder}" />
								<mkdir dir="${web.folder}" />

								<echo>jHeat: Moving all the libraries to the new application
									folder...</echo>
								<copy todir="${web.folder}">
									<fileset dir="${template.folder}" />
								</copy>

								<echo>jHeat: Generando a aplicação...</echo>
								<taskdef name="jHeatGenerate"
									classname="br.com.infowaypi.jheat.task.GeneratorTask"
									classpathref="maven.compile.classpath" />
								<jHeatGenerate />
								<echo>jHeat: Feito. Applicação está pronta. </echo>
							</target>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>selenium-maven-plugin</artifactId>
				<version>1.1</version>
				<executions>
					<execution>
						<id>start-server</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>start-server</goal>
						</goals>
						<configuration>
							<background>true</background>
							<logOutput>true</logOutput>
						</configuration>
					</execution>
					<execution>
						<id>stop-server</id>
						<phase>post-integration-test</phase>
						<goals>
							<goal>stop-server</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.codehaus.cargo</groupId>
				<artifactId>cargo-maven2-plugin</artifactId>
				<version>1.0.5</version>
				<executions>
					<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>
				</executions>
				<configuration>
					<wait>false</wait>
					<timeout>20000</timeout>
					<container>
						<containerId>tomcat6x</containerId>
						<zipUrlInstaller>
							<url>http://www.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip
							</url>
						</zipUrlInstaller>
					</container>
					<configuration>
						<home>${project.build.directory}/tomcat6x/</home>
						<properties>
							<cargo.servlet.port>8000</cargo.servlet.port>
						</properties>
						<deployables>
							<deployable>
								<pingURL>http://localhost:8000/capriovi/</pingURL>
								<properties>
									<context>/capriovi</context>
								</properties>
							</deployable>
						</deployables>
					</configuration>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
				<version>2.7.2</version>
				<configuration>
					<includes>
						<include>SuiteTestIT.java</include>
					</includes>
				</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>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>2.4</version>
				<executions>
					<execution>
						<id>instrument</id>
						<phase>verify</phase>
						<goals>
							<goal>cobertura</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<!-- <plugin> -->
			<!-- <groupId>org.codehaus.mojo</groupId> -->
			<!-- <artifactId>emma-maven-plugin</artifactId> -->
			<!-- <version>1.0-alpha-3</version> -->
			<!-- </plugin> -->

		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>br.com.infowaypi</groupId>
			<artifactId>jheat</artifactId>
			<version>1.0.1</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>jama</groupId>
			<artifactId>jama</artifactId>
			<version>1.0.2</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.8.2</version>
			<type>jar</type>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium.client-drivers</groupId>
			<artifactId>selenium-java-client-driver</artifactId>
			<version>1.0.2</version>
			<type>jar</type>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<reporting>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<formats>
						<format>html</format>
						<format>xml</format>
					</formats>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-pmd-plugin</artifactId>
				<version>2.5</version>
			</plugin>
		</plugins>
	</reporting>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to