[4.4.0] Package Private JUnit 5 Tests are not detected by Clover

Issue #71 resolved
James Spagnola created an issue

In JUnit5, tests and test suites can be package private. Clover does not detect JUnit5 tests marked as package private, although it will still detect JUnit5 tests marked as public.

Comments (10)

  1. Dmitry Timofeev


    I am not aware of all the scenarious where Clover uses test detection and if that affects correctness, but just FYI, JUnit 5 has a lot of ways to specify tests, and it would be awesome if OpenClover gains support of them. Here are the most notable, and you can find them all in the user guide:

    1. Parameterized tests — annotated with @ParameterizedTest

    2. Repeated tests — annotated with @RepeatedTest.

    3. Test templates — test cases that are invoked several times, annotated with @TestTemplate.

    4. Factories of dynamic tests (= created on the fly) — @TestFactory.

    Another feature that might make it a little more difficult to detect tests correctly is meta-annotations support, i.e., one can create their own annotation @CiOnlyTest and mark test methods with it.

  2. James Spagnola reporter

    Those are great points. I was short sighted in my write up of Junit 5 support as I was documenting my immediate issue.

    A side. I think I saw potentially similar issues with TestNG. TestNG doesn't require public modifiers (at least my intellij test runner ran fine). And TestNG allows @Test to be on the class level and subclasses will inherit the @Test, and any public void will become a test. Take that with a grain of salt.

  3. Dmitry Timofeev

    That's not a problem — probably, it makes sense to resolve the issue as is, and document what's left to be done to gain proper support of JUnit 5 & TestNG in separate tickets.

  4. Marek Parfianowicz

    Detection of package-private test has been fixed in commit 6efeaa9.

    The remaining patterns (parameterized tests, repeated tests, test templates etc) will be handled separately.

    I'm closing this one as fixed.

  5. Log in to comment