[arquillian-issues] [JBoss JIRA] (ARQ-1828) Replace Testrunner with a JUnit-Rule
Moinz Moinzen (JIRA)
issues at jboss.org
Mon Sep 22 10:07:03 EDT 2014
[ https://issues.jboss.org/browse/ARQ-1828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004783#comment-13004783 ]
Moinz Moinzen commented on ARQ-1828:
------------------------------------
A Junit Rule would also make it a lot easier to make some default setup, and then allowing the individual tests to add further information.
Example:
{code:java}
private static class MyTestRule implements TestRule {
ArquillianTestRule arquillianTestRule = new ArquillianTestRule();
private final WebArchive warModule = ShrinkWrap.create(WebArchive.class, "test.war")
.addPackages(true, "some.default.package")
.addAsManifestResource("MANIFEST.MF")
.addAsWebResource(EmptyAsset.INSTANCE, "beans.xml")
.addClass(ServerUserContext.class);
private final JavaArchive beansModule = ShrinkWrap.create(JavaArchive.class).addClass(ApiProducer.class);
public void addWarClass(Class clazz) {
warModule.addClass(clazz);
}
@Override
public Statement apply(Statement base, Description description) {
arquillianTestRule.setArchive(ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
.addAsModule(warModule)
.addAsModule(beansModule));
return arquillianTestRule.apply(base, description);
}
}
{code}
Usage:
{code:java}
public class MyTest {
@Rule
MyTestRule rule = new MyTestRule();
@Setup
public void setup(){
rule.addWarClass(MyOtherClass.class);
}
@Test
public void myTest() {
//Go!
}
}
{code}
> Replace Testrunner with a JUnit-Rule
> ------------------------------------
>
> Key: ARQ-1828
> URL: https://issues.jboss.org/browse/ARQ-1828
> Project: Arquillian
> Issue Type: Feature Request
> Reporter: Niels Niels
>
> At the moment all tests must run with
> @RunWith(Arquillian.class)
> This makes trouble if you need a runner with add or remove tests like Parameterized. I can't see what Arquillian.class do which can not be done with a JUnit-Rule. JUnit-Rules can be easily combined.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
More information about the arquillian-issues
mailing list