4 Replies Latest reply on Dec 11, 2014 1:21 PM by kpiwko

    Test runner delegation chain

    dan.j.allen

      Arquillian prides itself on allowing the developer to run the tests from their IDE or build tool without any special plugins. At the very least with JUnit, I propose that we support a chain of custom runners so that we can accommodate other testing frameworks, like Spock, that use the @RunWith approach.

       

      The reason this will work is because most of the other runners are alternate interpretors, meaning they can run tests written in a DSL. Arquillian is different in that it's more of a negotiator for local environment bootstrapping or remote execution of tests. Once Arquillian gets to the point where the test is run, it could hand off the responsibility.

       

      What I propose with JUnit is that we provide a complimentary annotation to @RunWith that the developer can use to define delegate chain of runners.

       

      @RunWith(Arquillian.class) @ThenRunWith({Spock.class, ...})

       

      @ThenRunWith (or alternate name) would be an annotation provided by Arquillian and interpreted by the Arquillian runner.

       

      I believe this would be a huge selling point for Arquillian, plus give us more examples.

        • 1. Re: Test runner delegation chain
          abertschi

          I am looking for the same feature.

          More than 4 years have already passed by since you wrote that suggestion.

          Has anybody already implemented that?

          • 2. Re: Test runner delegation chain
            kpiwko

            Hi Andrin,

             

            is there anything specific you want to solve by chaining runners? A lot of the stuff can be implemented by a @Rule with current version of JUnit, such as parametrization.

             

            Karel

            • 3. Re: Test runner delegation chain
              abertschi

              Hi Karel, Thanks for your answer.

               

              I was thinking about writing a small JUnit extension that injects annotated method arguments with objects that were serialized as xml files, so that they don't need to be constructed in the unit test and thus will not blow up my tests.

              Somewhat like:

               

              @Target({METHOD, TYPE})

              @Retention(RUNTIME)

              public @interface XmlObject {

                  String value();

              }

               

              @Test

              public void my_junit_test_method(@XmlObject("path/to/myClass-1.xml") MyClass input) {

                  input.fooBar(); // input is ready to use

              }

               

              I would then just write a junit runner that does the magic for the test.

              Because I also would like to apply this feature for my arquillian tests, I wondered whether multiple runners can be applied for an arquillian test.

              Since I need to package these xml-files into my deployable archive, I have to write a arquillian extension anyway for that purpose.

              So my question is obsolete: The arquillian extension would probably make use of jboss.arquillian.test.spi.TestEnricher to enrich my test methods.

               

              Andrin

              • 4. Re: Test runner delegation chain
                kpiwko

                Exactly, that's currently recommend approach for such type of a task.

                 

                Karel