1 Reply Latest reply on Jul 3, 2014 4:49 AM by adinn

    @Test annotation and Byteman

    rsearls

      I am trying to use Byteman with on a WS testsuite run within maven.  Byteman requires the @Test annotation.  When I use this annotation the JUnit startup method is never called and if I don't use the annotation Byteman does not recognize any test to run.   Is there any way around this?

        • 1. Re: @Test annotation and Byteman
          adinn

          Hi,

          I am trying to use Byteman with on a WS testsuite run within maven.  Byteman requires the @Test annotation.  When I use this annotation the JUnit startup method is never called and if I don't use the annotation Byteman does not recognize any test to run.   Is there any way around this?

           

          Strictly, Byteman does not require the @Test annotation. It is JUnit that requires the @Test annotation. Exactly what Byteman requires depends upon which version of JUnit you are using.

           

          For both JUnit 3 and 4 Byteman requires you to specify which rules you want injected into your code by placing @BMRule and @BMScript annotations on your test classes and methods. It identifies and responds to the presence of these annotations by overriding a small number of the behaviours provided by JUnit. However, for the most part it leaves the decisions about how the test code gets run to JUnit.

           

          Byteman adds behaviour to JUnit 3 by overriding the behaviour of TestCase which is why a JUnit 3 Byteman test needs to inherit from BMTestCase. It adds behaviour to JUnit4 by overriding JUnit4TestRunner which is why you have to add an @RunWith(BMUnitRunner) annotation to your test classes. In both cases all Byteman does is add extra behaviour. All overridden methods invoke super to run the parent behaviour.

           

          You said "the JUnit startup method is never called". Could you please explain what you mean by that? I am not aware of a 'startup' method in the JUnit code. It would also help if you could provide me with

           

          • the version of JUnit you are using
          • the version of Byteman you are using
          • an example test (the tests class and method code)
          • your maven pom's surefire configuration

           

          If you are not at liberty to provide the test code then a dummy which shows how you have annotated the test class and methods would help.