Details

    • Type: Wish Wish
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.11
    • Component/s: Junit 4.x support
    • Labels:
      None
    • Complexity:
      Intermediate
    • Number of attachments :
      3

      Description

      Is there any plan to support using JUNIT extensions such as @Category,@PreRequisite with Maven2 SureFire plugin?
      The JUNIT EXTENSION URL:
      http://www.junitext.org/

      We would like to specify the categories to run via a configurable option in the maven surefire plugin that supports JUNIT extensions

      See example Java Code: The following runs only tests with Category - Z.

      //In JUnit4
      JUnitCore core = new JUnitCore();
      // use for categories special listener, give some statistics
      core.addListener(new CategoryTextListener(System.out));
      Request req = Request.aClass(SpcfXXXXTest.class);
      core.run(req.filterWith(new CategoryFilter("Z")));

      1. SUREFIRE329_branch329.patch
        6 kB
        Nicolas Liochon
      2. surefire-329.txt
        117 kB
        Todd Lipcon
      3. surefire-329.txt
        29 kB
        Todd Lipcon

        Issue Links

          Activity

          Hide
          Nicolas Liochon added a comment -

          Kristian: Could you share the result of the tests you mentioned on the Aug. 29th? If the tests are ok, is it a feature you plan to integrate soon? Thank you!

          Show
          Nicolas Liochon added a comment - Kristian: Could you share the result of the tests you mentioned on the Aug. 29th? If the tests are ok, is it a feature you plan to integrate soon? Thank you!
          Hide
          Nicolas Liochon added a comment -

          I tested the branch SUREFIRE329 above on Apache HBase, mainly in forkMode=always or forkMode=once, with JUnit 4.8.2, and I have been able to make it work with some modifications on surefire. I attach the patch here if you want to reuse some elements. The issues I had are:

          1) logs on console despite a redirect setting
          2) excludedGroups was not taken into account, it seems that there is a confusion between excludedgroups & excludegroups (see the missing 'd')
          3) the filtering was not done

          I also had an issue linked to JUnit: JUnit fully initializes the classes to check if it must be included or not. It means creating the static variable & so on. If the initialization is not possible for any reason (for example complex initialization dependent on the class loader) it breaks... I created an issue in JUnit for that: https://github.com/KentBeck/junit/issues/359. It works fine with a minor modification on JUnit. We need it for HBase, it won't be necessary for everybody I think.

          Using forkMode=once, with only excludedGroups (no groups specify) does not work (junit exception). I didn't dig in this one as in our case forkMode=once without groups is barely used. It could be a pure JUnit issue.

          Show
          Nicolas Liochon added a comment - I tested the branch SUREFIRE329 above on Apache HBase, mainly in forkMode=always or forkMode=once, with JUnit 4.8.2, and I have been able to make it work with some modifications on surefire. I attach the patch here if you want to reuse some elements. The issues I had are: 1) logs on console despite a redirect setting 2) excludedGroups was not taken into account, it seems that there is a confusion between excludedgroups & excludegroups (see the missing 'd') 3) the filtering was not done I also had an issue linked to JUnit: JUnit fully initializes the classes to check if it must be included or not. It means creating the static variable & so on. If the initialization is not possible for any reason (for example complex initialization dependent on the class loader) it breaks... I created an issue in JUnit for that: https://github.com/KentBeck/junit/issues/359 . It works fine with a minor modification on JUnit. We need it for HBase, it won't be necessary for everybody I think. Using forkMode=once, with only excludedGroups (no groups specify) does not work (junit exception). I didn't dig in this one as in our case forkMode=once without groups is barely used. It could be a pure JUnit issue.
          Hide
          Nicolas Liochon added a comment -

          patch on top of the branch 329.

          Show
          Nicolas Liochon added a comment - patch on top of the branch 329.
          Hide
          Kristian Rosenvold added a comment -

          Fixed in r1199853, thanks for the patches !

          @nkeywal I only applied some of your changes; this was a big patch and it was quite complex. Your patch covered various topics and I would appreciate it if you create individual issues/patches. There are other open issues relating to stdout/stderr logging, for 2.10 so this will be fixed in that context. As for the exclude stuff, if it does not work to satisfaction, please resubmit patch with testcase. I tried to standardize on one spelling of "excludedgroups", unsure why there needs to be two different properties.

          To make a testcase you can adapt/modify the test project in surefire-integration-tests/src/test/resources/junit48-categories and add test cases to JUnit48TestCategoriesIT

          Show
          Kristian Rosenvold added a comment - Fixed in r1199853, thanks for the patches ! @nkeywal I only applied some of your changes; this was a big patch and it was quite complex. Your patch covered various topics and I would appreciate it if you create individual issues/patches. There are other open issues relating to stdout/stderr logging, for 2.10 so this will be fixed in that context. As for the exclude stuff, if it does not work to satisfaction, please resubmit patch with testcase. I tried to standardize on one spelling of "excludedgroups", unsure why there needs to be two different properties. To make a testcase you can adapt/modify the test project in surefire-integration-tests/src/test/resources/junit48-categories and add test cases to JUnit48TestCategoriesIT
          Hide
          Nicolas Liochon added a comment -

          Hi Kristian, thanks for having integrated the functionality. It's really great. My tests and changes were driven a lot by the forkMode=always. I am going to check the version on trunk and I will create some specific jira if I find something.

          Show
          Nicolas Liochon added a comment - Hi Kristian, thanks for having integrated the functionality. It's really great. My tests and changes were driven a lot by the forkMode=always. I am going to check the version on trunk and I will create some specific jira if I find something.

            People

            • Assignee:
              Kristian Rosenvold
              Reporter:
              Anuj Kathuria
            • Votes:
              37 Vote for this issue
              Watchers:
              31 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: