Skip to content

JUnit5 integration #9

Description

@ashleyfrieze

There are cases when the lambda-based wrappers don't quite hit the mark.

For example, let's say we're using the @SpringBootTest plugin, and our SpringContext takes environment variables as part of its input. This might be resolved by something like:

classMainTest {
// initialise some environment variables somehow@Nested@SpringBootTestclassSpringTest {
}
}

In the above, it's not possible to run the inner test within a withSystemLambda( () -> {}) construct.

I have a solution for this. There could be a JUnit5 extension which does the necessary setup/teardown, rather than the equivalent JUnit4 Statement or try/finally of the lambda approach.

I've hacked a working example of this together. As the methods to do setup/teardown within this project are private, my hacked version does some weird stuff (with the JUnit4 version of system rules).

If there were to be such a JUnit5 plugin, raised as a PR, which project would it belong in? If it were to be done without hacking, some of the setup/teardown methods of this codebase would need to be exposed - to the plugin at least.

@stefanbirkner what do you think about the possibility of introducing this extension?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions