Hi all,
I just commited (r995) changes to the AS5 plugin integration tests that I hope
will bring a bit more clarity to the way we set up the tests.
First of all, the AbstractResourceTest doesn't define any @Test methods
anymore. The methods are kept in the class but made protected. This makes it
possible for the actual tests inheriting from this class to decide what tests
will be called by inheriting those methods and making them public.
Secondly, the @Test annotations are only defined on class level on the concrete
test classes. All the tests belong to "as5-plugin" group. This enables us to
disable them in the pom.xml with a single command. If you need to do some
setup, you can either create a @BeforeTest method (but beware that this method
will be run before any @BeforeGroups methods) or in case you have a setup
method common to more test classes you can do it like this:
class SetupClass {
@BeforeGroups(groups = "my-group")
public void setup() {}
}
@Test(groups = {"as5-plugin", "my-group"})
class Test {
public void test() {}
}
In a more complicated use case for EJB2 tests the following is done:
abstract class AbstractEjb2Test {
@BeforeGroups(groups = "as5-plugin-ejb2")
public void deployJars() {}
}
@Test(groups = {"as5-plugin", "as5-plugin-ejb2", ...})
class Ejb2SLSBTest extends AbstractEjb2Test {
@BeforeGroups(groups = "as5-plugin-ejb2", dependsOnMethods =
"deployJars")
public void setup() {}
... test methods ...
}
This way we can have 1 abstract parent class that deploys all the necessary
jars and a number of child classes, each with its own setup methods that will
be called only after the jars are deployed.
The EjbSLSBTest.setup() method needs to be annotated as @BeforeGroups, not as
@BeforeTest, because the @BeforeTest method would be called before all the
@BeforeGroups (and it is not possible to declare it dependent on the
deployJars method due to the way TestNG works).
Hope this makes sense,
Lukas
Show replies by date