Skip to content

Standardize Test Execution#833

Open
gallardo wants to merge 2 commits intoalkacon:masterfrom
gallardo:chore/standardize-test-execution-PR3
Open

Standardize Test Execution#833
gallardo wants to merge 2 commits intoalkacon:masterfrom
gallardo:chore/standardize-test-execution-PR3

Conversation

@gallardo
Copy link
Contributor

@gallardo gallardo commented Jan 9, 2026

This PR standardizes unit test execution while preserving backward compatibility and enabling native IDE integration.

Changes:

  • Enhanced testSingle:
    • Enabled Standard Test Selection: Fully supports test case selection via --tests (default convention in Gradle).
    • Keeps Default Behavior: Defaults to TestCmsSystemInfo* when no explicit property or filter is provided.
    • Legacy Property Support: Fully supports -PtestCaseToRun=<TestClass> property, emitting a deprecation warning but functioning exactly as before.
  • Simplified test task: Always executes org.opencms.test.AllTests for backward-compatible CI behavior.
  • Enhanced test configuration:
    • Refactored code of test tasks to eliminate redundancy.
    • Fixed testImplementation to extend setupImplementation for correct classpath.

Usage:

# Run the complete test suite (CI default)
./gradlew test

# Run the default testSingle behavior (TestCmsSystemInfo*)
./gradlew testSingle

# Run a specific test using testSingle with --tests
./gradlew testSingle --tests org.opencms.i18n.TestCmsEncoder.testDecodeHtmlEntities

Verification:

The following validations were performed to ensure parity, backward compatibility, and IDE integration:

  • Backward Compatibility:
    • Verified that ./gradlew testSingle (without arguments) executes TestCmsSystemInfo* as before.
    • Confirmed that ./gradlew test executes org.opencms.test.AllTests, maintaining consistent CI behavior.
  • IDE Integration: Verified that IDEs can execute individual tests using the test task with native --tests filtering without conflicts (See notice below).
  • Explicit Filters: Confirmed that ./gradlew testSingle --tests <ClassName> and ./gradlew testSingle --tests <ClassName.methodName> correctly override the default and run only the specified tests (See notice below).

Notice on Gradle Test Filtering and JUnit 3 Suites

When using legacy JUnit 3 tests that implement a public static Test suite() method, Gradle's --tests Class.method filtering does not apply at the method level as one might expect. In this case, JUnit executes exactly the tests returned by the suite (typically the whole test class), which overrides Gradle's method-level selection. This is expected behavior of JUnit 3's suite-based execution model, not a Gradle bug. Tests without a suite() method use default discovery and therefore support method-level filtering correctly.

@gallardo gallardo marked this pull request as draft January 9, 2026 18:05
@gallardo
Copy link
Contributor Author

gallardo commented Jan 9, 2026

I want to test this PR a bit more before giving it the green light for review.

- Enhanced testSingle to support native IDE unit test execution
- Removed logic for selecting test cases via the `testCaseToRun` property
- Refactored test code to eliminate redundancy
- Added inputs.dir for test/data and webapp to support incremental builds
- Fixed testImplementation to extend from setupImplementation

This change enables native IDE test execution and simplifies the build logic.
To preserve backward compatibility, this change restores the logic for selecting a test case via the `testCaseToRun` property.
@gallardo gallardo force-pushed the chore/standardize-test-execution-PR3 branch from 57eea8a to 7e654dd Compare January 13, 2026 16:18
@gallardo
Copy link
Contributor Author

I have split this PR into two commits to allow selectively removing the old selection logic based on the non-standard testCaseToRun property.

@gallardo gallardo marked this pull request as ready for review January 13, 2026 16:22
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

Comments