Skip to content

Investigate separate module-info for tests #79

Closed as not planned
Closed as not planned

Description

@gselzer

Maven's Surefire documentation suggests adding a second module for tests.

  • This seems to confuse Eclipse, and makes JUnit tests difficult to run. I seem to get the following error, having the following project hierarchy:
    image
    image
  • This would also require the test module to have a different name than the main module. In the example above, we have main module org.scijava.discovery.therapi and test module org.scijava.discovery.therapi.test

As it currently stands, the test classes are on the classpath, which prevents us from having to declare test-related dependencies in the main package's module-info. It would be smooth, however, if the test package was also a module

Activity

  1. added this to the unscheduled milestone on Oct 11, 2021
  2. self-assigned this
    on Oct 11, 2021
  3. gselzer commented on Oct 11, 2021

    @gselzer
    MemberAuthor

    Interestingly enough, when I had the test module-info, scijava/scijava-discovery-therapi/target/test-classes was still on the classpath. This means that test scope dependencies do not have to be required in the main module-info if we do not have the separate test module.

    For interested parties, this can be seen in scijava/scijava-discovery-therapi in scijava incubator, commit 3e07b868315a4e5325260a228159c58c4b369a87

  4. hinerm commented on Oct 12, 2021

    @hinerm
    Member

    I agree that we do not need a module-info.java in src/test. This seems consistent with answers to https://stackoverflow.com/q/46613214

  5. gselzer commented on Oct 21, 2021

    @gselzer
    MemberAuthor

    I think I made a bit of a mistake; while the commit I linked did have the running module's classes on the classpath, they are somehow still "on" the modulepath, and their exports/opens still apply (this can be seen with commit scijava/incubator@3bd4ee7b). @hinerm @ctrueden we should look into patching the module-info.java at test runtime, similar to the way done here with module-info.test. It's not the prettiest solution, but I'd prefer it over creating test modules.

  6. gselzer commented on Oct 18, 2023

    @gselzer
    MemberAuthor

    I think that whatever we have working now is good enough, as it passes in IntelliJ, on CLI, and on CI, and we don't have to do anything funny with the module infos. So I'm going to close this as unplanned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions