Skip to content

feat: add Groovy/Spock test file pattern support#299

Draft
rcasia wants to merge 7 commits into
mainfrom
feature/add-groovy-spock-support
Draft

feat: add Groovy/Spock test file pattern support#299
rcasia wants to merge 7 commits into
mainfrom
feature/add-groovy-spock-support

Conversation

@rcasia
Copy link
Copy Markdown
Owner

@rcasia rcasia commented May 21, 2026

Summary

Add support for discovering and running Groovy/Spock test files () alongside Java test files.

Changes

  • lua/neotest-java/model/patterns.lua: Added and constants for matching Groovy test files
  • lua/neotest-java/core/file_checker.lua: Updated file extension handling to strip in addition to when matching test class name patterns

What this enables

Users can now run Spock framework tests written in Groovy within Maven or Gradle projects. Files matching patterns like:

will be discovered and executed by neotest-java.

Backward compatibility

No breaking changes. Existing Java test detection continues to work unchanged.


Fixes #194

rcasia added 2 commits May 22, 2026 00:01
Extend test file discovery to support .groovy files alongside .java.
Adds GROOVY_TEST_FILE_PATTERNS and GROOVY_TEST_FILE_REGEXES to the
patterns module and updates file_checker to strip .groovy extension
when matching test class name patterns.

Fixes #194
Add unit tests for Groovy file pattern matching in file_checker:
- Groovy test file discovery (*Spec.groovy, *Test.groovy, *IT.groovy)
- Groovy non-test file exclusion
- Groovy files in main folder exclusion

Add E2E test suite (groovy_support_spec.lua) with complete Maven+Groovy fixture:
- CalculatorSpec.groovy - Spock specification tests (4 tests)
- UserServiceTest.groovy - Groovy JUnit tests (4 tests, 1 intentional failure)
- Tests verify discovery, execution, and pass/fail reporting

Fixture includes pom.xml with GMavenPlus plugin, Spock dependency,
and source files for both Java and Groovy tests.

Fixes #194
@rcasia rcasia force-pushed the feature/add-groovy-spock-support branch from 55bf727 to b00708f Compare May 21, 2026 22:10
rcasia added 5 commits May 22, 2026 00:15
Update run-all.sh to:
- Discover and run all fixtures automatically (not just maven-simple)
- Find both .java and .groovy test files in src/test/java and src/test/groovy
- Support *Test, *Spec, and *IT naming conventions for both languages

Update run.lua to:
- Extract expected class name from .groovy files (not just .java)
- Derive snapshot file names for .groovy test files

Update minimal_init.lua to:
- Include tests/e2e/*_spec.lua in test collection (previously only tests/unit)
- Ensures groovy_support_spec.lua and full_workflow_spec.lua run in CI

Fixes #194
Fixes exit code handling so fixtures without test files are skipped
gracefully instead of counting as failures.

Fixes #194
Fixes exit code handling so fixtures without test files are skipped
gracefully instead of counting as failures.

Fixes #194
Fixes exit code handling so fixtures without test files are skipped
gracefully instead of counting as failures.

Fixes #194
Add unit tests for Groovy position discovery:
- Spock feature methods with string literal names (def "test"())
- JUnit-style annotated methods in Groovy (@test)

Tests skip gracefully when Groovy treesitter parser is not compiled.

Fixes #194
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.

[FEATURE REQUEST] Add support for Groovy/Spock test file patterns in neotest-java

1 participant