Skip to content

JUnit 5: How to support dynamic tests? #280

Open

Description

@janschaefer

It is unclear at the moment how dynamic tests should by supported by JGiven, as JUnit 5 provides no life-cycle hooks for them. Any suggestions are welcome!

Activity

  1. ahus1 commented on Jan 2, 2017

    @ahus1
    Contributor

    Suggestion No 1: open a bug with JUnit5 :-) but maybe suggestion No 2 could allow to explore some scenarios first to make a point.

    Suggestion No 2: I had cases where I wrapped lambdas with a static function. It would look like this:

    dynamicTest("1st dynamic test", wrapForJGiven(() -> assertTrue(true)))

    JGiven could first prepare whatever is necessary, then call the lambda, and afterwards clear up after the lambda. This could offer some basic lifecycle handling. But I how would you take it from here? But I see that you might want to grab the first parameter "1st dynamic test", wouldn't you?

  2. janschaefer commented on Jan 2, 2017

    @janschaefer
    ContributorAuthor

    Maybe JGiven could provide a method dynamicJGivenTest that is just a wrapper around dynamicTest. That might even be easy to implement.

  3. ahus1 commented on Jan 2, 2017

    @ahus1
    Contributor

    Like that - and you can capture the first argument as well.

  4. janschaefer commented on Jan 4, 2017

    @janschaefer
    ContributorAuthor

    PR #289

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions