Skip to content

[Core] Add object-factory option to CLI and CucumberOptions #1710

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

Merged
merged 9 commits into from
Jul 30, 2019
Merged

[Core] Add object-factory option to CLI and CucumberOptions #1710

merged 9 commits into from
Jul 30, 2019

Conversation

ralphkar
Copy link
Contributor

Summary

In order to provide different test configurations it might be useful to use different object factories when working with a DI framework. This is described in issue #1690.

Details

  • The annotations for JUnit and TestNG now allow to specify the class to instantiate as object factory.
  • A CLI flag has been added to allow the specification of an object factory on the command line (--object-factory).
  • Some minor refactorings along the way.

Motivation and Context

  • It is now possible to use different object factories in a Cucumber test suite. Features need to be separated (using tags) and can be grouped as separate tests that are annotated with different CucumberOptions.
  • For each specification of CucumberOptions a different objectFactory can be specified. That way different feature tests can e.g. use differently configured injectors.
  • It is no longer necessary to specify an object factory in cucumber.properties.
  • Object factories are loaded via the ServiceLoader and need to be specified in the file META-INF/services/io.cucumber.core.backend.ObjectFactory. Multiple implementations can be given here.

How Has This Been Tested?

Unit tests have been added and a production test has been executed with our product.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@mpkorstanje mpkorstanje changed the title cucumber-jvm issue no. 1690 [Core] Add object-factory option to CLI and CucumberOptions Jul 29, 2019
@mpkorstanje
Copy link
Contributor

Cheers looks good. Just a few small things.

@ralphkar
Copy link
Contributor Author

I have made the requested changes. I think the PR is ready. Maybe at some point in the future someone should write a short abstract on how to use object factories in v5.

@ralphkar ralphkar requested a review from mpkorstanje July 30, 2019 07:11
@mpkorstanje mpkorstanje merged commit bd8d2b5 into cucumber:develop-v5 Jul 30, 2019
@mpkorstanje
Copy link
Contributor

Cheers!

Maybe at some point in the future someone should write a short abstract on how to use object factories in v5.

You wouldn't be happen to volunteer? It doesn't need to be a full blown doc. A short brief in a readme of the core module will do.

@ralphkar
Copy link
Contributor Author

Maybe at some point in the future someone should write a short abstract on how to use object factories in v5.

You wouldn't be happen to volunteer? It doesn't need to be a full blown doc. A short brief in a readme of the core module will do.

As requested -> #1715

mpkorstanje pushed a commit that referenced this pull request Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants