Skip to content

Maven surefire uses wrong provider for Spring Batch Core #4121

Closed
@hpoettker

Description

@hpoettker

Issue

There are failing tests in Spring Batch Core. Both on the main branch and in the release 5.0.0-M3. They are in the classes

  • InlineDataSourceDefinitionTests
  • JobBuilderConfigurationTests
  • JobLoaderConfigurationTests
  • TransactionManagerConfigurationWithBatchConfigurerTests
  • TransactionManagerConfigurationWithoutBatchConfigurerTests
  • ConcurrentTransactionTests

During a Maven build currently no tests are executed in Spring Batch Core as Maven Surefire chooses the provider for JUnit 5 while all tests are written in JUnit 4 and the JUnit 5 vintage engine is not on the classpath. This can be verified by executing e.g.

./mvnw clean test -pl spring-batch-core

Root cause

The tests have been effectively disabled in #4065 by the change in the pom.xml of Spring Batch Core: https://github.com/spring-projects/spring-batch/pull/4065/files#diff-690b0d85920e9a80c4b4883c05b470e89b6bcd42f5721e38625d25b638a548a6

The artifact micrometer-test artifact has transitive dependencies on JUnit Jupiter which leads to Maven Surefire using a Junit 5 provider instead of Junit 4. And the JUnit 5 provider silently ignores the JUnit 4 tests without the vintage engine.

Tests have started failing with the commit 31af573. Since then, some other commit has led to failures in JobLoaderConfigurationTests which did not fail in this commit.

Possible fixes for the build

I think the best solution to get the build working again is to add the JUnit Vintage Engine to Spring Batch Core. If it's added, the tests are again executed as expected.

Alternatively, JUnit Jupiter dependencies could be excluded from micrometer-test. This works too but the problem might resurface easily.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions