Skip to content

[junit-platform-engine] ClassCastExceptions running Surefire while test succeeds in IntelliJ #1837

Closed
@nickstolwijk

Description

@nickstolwijk

Describe the bug
I have a working test with a DefaultParameterTransformer (using Jackson). When I run this test in IntelliJ it succeeds. Although when running with Surefire, the test fails.

Output with Intellij:

Mapping '1.1.0' to 'java.lang.String'.
We wants a version: 1.1.0
Mapping '1.1.0' to 'nl.blue4it.stolwijk.sandbox.cucumber5.model.Version'.
We gets a version: Version{major=1, minor=1, patch=0}

1 Scenarios (1 passed)
2 Steps (2 passed)
0m0,513s

Output with Surefire:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running Version number check
Mapping '1.1.0' to 'java.lang.Object'.
We wants a version: 1.1.0
Mapping '1.1.0' to 'java.lang.Object'.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.422 s <<< FAILURE! - in Version number check
[ERROR] User wants to use 1.1.0 as version.  Time elapsed: 0.416 s  <<< ERROR!
java.lang.ClassCastException: class java.lang.String cannot be cast to class nl.blue4it.stolwijk.sandbox.cucumber5.model.Version (java.lang.String is in module java.base of loader 'bootstrap'; nl.blue4it.stolwijk.sandbox.cucumber5.model.Version is in unna
med module of loader 'app')

To Reproduce
Steps to reproduce the behavior:

  1. Clone the repository at 'https://github.com/nickstolwijk/cucumber-platformengine-surefire-issue'
  2. Run mvn verify
  3. See the build fail.
  4. Import into IDE.
  5. Run feature
  6. See the feature succeed

Expected behavior
The feature should succeed both in Surefire as in IntelliJ.

Your Environment

  • Cucumber version 5.0.0 RC2
  • Operating System and version: Windows 10
  • IntelliJ 2019.3
  • Build tool: Maven 3.6.3
  • Java: OpenJDK 11.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions