How to reuse test methods (A/B integration testing) ?
tvibes Nov 15, 2014 8:37 AMHi everybody,
I would like to do some kind of A/B integration testing. Between my A tests and my B tests I only need to change what is deployed in the container.
To achieve that I have 2 classes, and I use inheritance to avoid code duplication on test methods (I have 24 test scenarios) :
/**
* Test A
*/
@RunWith(Arquillian.class)
public class TestA {
@Deployment
public static WebArchive createDeployment() {
WebArchive archive = ...; //Put my stuff in the WebArchive
//my JSF page for testA
archive.addAsWebResource(new File("src/it/webapp/testA.xhtml"), ArchivePaths.create("/index.html") );
return archive;
}
@Test
@InitialPage("/index.jsf")
@BrowserVersion(Browser.FIREFOX_3_6)
public void shouldDoSomething(JSFServerSession server, JSFClientSession client){
//... nothing interesting here
}
@Test
@InitialPage("/index.jsf?param1=value1")
@BrowserVersion(Browser.FIREFOX_3_6)
public void shouldDoSomethingElse(JSFServerSession server, JSFClientSession client){
//... nothing interesting here
}
//[...]
@Test
@InitialPage("/index.jsf")
@Cookies(names = {"aCookieName"}, values = {"aiuzshgtu"})
@BrowserVersion(Browser.FIREFOX_3_6)
public void shouldDoSomething_24(JSFServerSession server, JSFClientSession client){
//... nothing interesting here
}
}
/**
* Test B
*/
@RunWith(Arquillian.class)
public class TestB extends TestA {
@Deployment
public static WebArchive createDeployment() {
WebArchive archive = TestA.createDeployment(); //Reuse the WebArchive of testA
//overrides my JSF page for testB
archive.addAsWebResource(new File("src/it/webapp/testB.xhtml"), ArchivePaths.create("/index.html") );
return archive;
}
}
Since last week it worked as we were using a (pretty) old Arquillian version (1.0.1.Final). I upgraded to the last version and it doesn't work anymore as Arquillian now supports multiple @Deployment annotated methods. So when I execute TestB class, Arquillian looks in TestA class, finds the @Deployment method and reports the conflict :-)
But I can't find a good design to achieve our A/B testing.
Is this use case is cover by Arquillian? Is someone here has already done that with Arquillian?
Some enlightment would be greatly appreciated (even a RTFM) :-)
I currently use :
- Arquillian 1.1.5.Final
- JSFUnit 2.0.0.Beta2