Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create proxy to allow JGiven to run with Class lifecycles #883

Open
l-1squared opened this issue May 11, 2022 · 3 comments
Open

Create proxy to allow JGiven to run with Class lifecycles #883

l-1squared opened this issue May 11, 2022 · 3 comments

Comments

@l-1squared
Copy link
Collaborator

l-1squared commented May 11, 2022

Especially TestNG cannot run in parallel with JGiven using injected stages, due to its lifecycle strategy.
It would be nice to create a proxy for TestNG and by Extension JUnit5 to support those two testing frameworks more completely.

Follow-up for #829

@adrian-herscu
Copy link

Trying to get around the parallel dataprovider limitation that JGiven has with its TestNG integration...

In my scenario class defined stage fields as following (without using the @ScenarioStage annotation, which we all know it does not work well with parallel dataproviders):

    protected ThreadLocal<ElasticSearchFixtures<?>>  elasticSearchFixtures = new ThreadLocal<>();
    // and similar for ElasticSearchActions and ElasticSearchVerifications stages

and initialization methods, like this:

    protected ElasticSearchFixtures<?> given(
        final ElasticSearchFixtures<?> fixtures) {
        elasticSearchFixtures.set(fixtures);
        return fixtures;
    }

then, in scenario methods, I used these like this:

        given(new ElasticSearchFixtures<>())
            .elastic_search(configuration().elasticSearchClient())
            .and().indexed_by(configuration().elasticSearchIndex())
            .and().storing(JsonNode.class);

It all compiles fine, but fails with NPE because the fields in ElasticSearchActions and ElasticSearchVerifications are not injected.

I am not familiar with the injection mechanism used by JGiven, perhaps you can suggest something?

@l-1squared
Copy link
Collaborator Author

Do you have a more comprehensive sample? I am failing to understand, where these ElasticSearchActions and ElasticSearchVerifications are in the first place...
Are these supposed to be scenario states?

@adrian-herscu
Copy link

Do you have a more comprehensive sample? I am failing to understand, where these ElasticSearchActions and ElasticSearchVerifications are in the first place... Are these supposed to be scenario states?

see #1469 -- both are about how to use multiple stages in a parallel testing mode

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

No branches or pull requests

2 participants