Skip to content

Add unit tests for JavaLocator - #932

Open
vasiliy-mikhailov wants to merge 1 commit into
davidB:masterfrom
vasiliy-mikhailov:add-javalocator-tests
Open

Add unit tests for JavaLocator#932
vasiliy-mikhailov wants to merge 1 commit into
davidB:masterfrom
vasiliy-mikhailov:add-javalocator-tests

Conversation

@vasiliy-mikhailov

@vasiliy-mikhailov vasiliy-mikhailov commented Jun 29, 2026

Copy link
Copy Markdown

Adds unit tests for util.JavaLocator, which previously had little coverage of its executable-resolution logic.

The new tests cover findExecutableFromToolchain(...):

  • resolving java from the java.home system property
  • resolving java from the JAVA_HOME environment variable
  • the JDK-with-jre layout (sibling bin/java) and the fallback when no sibling bin exists
  • both IllegalStateException paths (java.home / JAVA_HOME set but no bin/java), asserting the exact messages

They use TemporaryFolder for throwaway JDK layouts and save/restore java.home in @Before/@After so no global state leaks, and reuse the existing environmentVariables rule.

I found the gaps with PIT mutation testing; the additions take the class from 34 to 77 killed mutants. One test (shouldNotEnterJreBranchWhenJavaHomeDoesNotEndWithJre) specifically pins the endsWith("jre") branch, which nothing covered before.

Additive only: +8 tests, no production changes.


How this was produced

This PR was generated with an AI-assisted pipeline built around mutation testing (PIT). The pipeline mutates the target class (flipping conditions and changing boundary/edge cases) and runs the existing tests against each mutant. Where a mutant survives (the existing tests do not catch that edge case), it writes a focused test for that case and reruns PIT to confirm the new test actually kills that specific mutant. So every added test is verified to catch a concrete edge case the suite missed before, rather than being speculative or redundant. The change is additive only (no production code modified), and the module builds green under its CI JDK.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant