26 abril 2010

ant tasks in maven

Para correr los test del build.xml desde maven:

TestNG & Maven: How to configure it correctly


<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>pre-test</id>
<phase>process-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<move todir="${project.build.outputDirectory}">
<fileset dir="${project.build.outputDirectory}">
<!-- include list of files you want to have hidden during tests -->
<include name="META-INF/persistence.xml"/>
</fileset>
<mapper type="glob" from="*" to="*~"/>
</move>
</tasks>
</configuration>
</execution>
<execution>
<id>post-test</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<move todir="${project.build.outputDirectory}">
<fileset dir="${project.build.outputDirectory}" defaultexcludes="false">
<include name="**/*~"/>
</fileset>
<mapper type="glob" from="*~" to="*"/>
</move>
</tasks>
</configuration>
</execution>
</executions>
</plugin>

SeamTest and Maven

SeamTest and Maven


Using SeamTest with Maven can be a challenge because the Embedded JBoss container on which SeamTest relies is not very classpath friendly. It brings its own solar system of JAR files with it and those can easily conflict with the classpath built by Maven. Please see the following thread on how best to integrate the two:

TestNG and Maven - How To Configure It Correctly

Play close attention to the responses Dan gives.

para probar Arquilian en hermes

Getting started

We've promised you that integration testing with Arquillian is no more complicated than writing a unit test. Now it's time to prove it to you. In this chapter, we'll look at what is required to setup Arquillian in your project, how to write an Arquillian test case, how to execute the test case and how the test results are displayed. That sounds like a lot, but you'll be writing your own Arquillian tests in no time. (You'll also learn about Chapter 7, Debugging remote tests in Chapter 7).

TestNG

reference-guide

@BeforeSuite: The annotated method will be run before all tests in this suite have run.

@AfterSuite:
The annotated method will be run after all tests in this suite have run.

@BeforeTest
: The annotated method will be run before any test method belonging to the classes inside the tag is run.

@AfterTest
: The annotated method will be run after all the test methods belonging to the classes inside the tag have run.

@BeforeGroups
: The list of groups that this configuration method will run before. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked.

@AfterGroups
: The list of groups that this configuration method will run after. This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked.

@BeforeClass
: The annotated method will be run before the first test method in the current class is invoked.

@AfterClass
: The annotated method will be run after all the test methods in the current class have been run.

@BeforeMethod
: The annotated method will be run before each test method.

@AfterMethod
: The annotated method will be run after each test method.

@Parameters
Describes how to pass parameters to a @Test method.

@Test

dependsOnGroups
The list of groups this method depends on.
dependsOnMethods
The list of methods this method depends on.
expectedExceptions
The list of exceptions that a test method is expected to throw. If no exception or a different than one on this list is thrown, this test will be marked a failure.
sequential
If set to true, all the methods on this test class are guaranteed to run sequentially, even if the tests are currently being run with parallel="methods". This attribute can only be used at the class level and it will be ignored if used at the method level.

5.13 - Running TestNG programmatically

You can invoke TestNG from your own programs very easily:
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { Run2.class });
testng.addListener(tla);
testng.run();

25 abril 2010

Arquilian

Test-in container

Arquillian provides a easy mechanism to test your application code inside a remote or embedded container or by interacting as a client of the container.


To avoid introducing unnecessary complexity into the developer's build environment, Arquillian integrates transparently with familiar testing frameworks (e.g., JUnit 4, TestNG 5), allowing tests to be launched using existing IDE, Ant and Maven test plugins without any add-ons.