• Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 1.2.0.Final
    • None
    • Base Implementation
    • None

      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.

            [ARQ-1828] Replace Testrunner with a JUnit-Rule

            We haven't replaced it but shipped rules as an alternative to the runner. 1.2.0.Final should hit Maven Central pretty soon.

            You can read all about it here http://arquillian.org/arquillian-core/#_rules

            Bartosz Majsak added a comment - We haven't replaced it but shipped rules as an alternative to the runner. 1.2.0.Final should hit Maven Central pretty soon. You can read all about it here http://arquillian.org/arquillian-core/#_rules

            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:

            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);                                                  
                }                                                                                                        
            }                                                                                                            
            

            Usage:

            public class MyTest {
                @Rule
                MyTestRule rule = new MyTestRule();
            
               @Setup
                public void setup(){
                    rule.addWarClass(MyOtherClass.class);
                }
            
                @Test
                public void myTest() {
                    //Go!
                }
            }
            

            Moinz Moinzen (Inactive) added a comment - 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: 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); } } Usage: public class MyTest { @Rule MyTestRule rule = new MyTestRule(); @Setup public void setup(){ rule.addWarClass(MyOtherClass.class); } @Test public void myTest() { //Go! } }

              dipakpawar231 Dipak Pawar (Inactive)
              opensource21_jira Niels Niels (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: