Skip to content

ModuleDiscoverer unit tests #293

@ascopes

Description

@ascopes

We need to write a couple of unit tests for the module discoverer utility class.

https://github.com/ascopes/java-compiler-testing/blob/main/java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/ModuleDiscoverer.java

These tests should be fine to just static-mock the internal module finder class.

In addition, since it is a utility class, the test class should implement the UtilityClassTestTemplate at https://github.com/ascopes/java-compiler-testing/blob/main/java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/helpers/UtilityClassTestTemplate.java

For example:

@DisplayName("ModuleDiscoverer tests")
@ExtendWith(MockitoExtension.class)
class ModuleDiscovererTest
    implements UtilityClassTestTemplate {

  @Mock
  MockStatic<ModuleFinder> moduleFinderClass;

  @Mock
  ModuleFinder moduleFinderInstance;

  @BeforeEach
  void setUp() {
    moduleFinder
        .when(() -> ModuleFinder.of(any()))
        .thenReturn(moduleFinderInstance);
  }

  ...
}

Metadata

Metadata

Assignees

Labels

good first issuegood first issue for contributorstestingImprovements to test packs

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions