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

Allow TestNG Cucumber runner to use composition instead of inheritance #622

Merged
merged 3 commits into from
Nov 12, 2013

Conversation

martykube
Copy link
Contributor

Right now to use the TestNG runner you need to inherit from AbstractTestNGCucumberTests. I'm working on a large existing project where we have a base test class that does a lot of framework setup. The only solution I had was to copy AbstractTestNGCucumberTests into my project and modify it to inherit from our base class.

This patch removes the need to inherit from AbstractTestNGCucumberTests. You can still do so if you want.

@ghost ghost assigned ffbit Nov 5, 2013
@ffbit
Copy link
Contributor

ffbit commented Nov 5, 2013

@martykube great job!
That's TestNG day has come!
I've run your code code and had a look at the test report of the java-calculator-testng test project.
And I found your idea and code brilliant.
I'll merge it in a couple of days, if there no comments/questions/suggestions on your code.

off topic
I can see that TestNG becomes more and more popular.
Could you, please, provide a couple of good links or books to read on TestNG?
Thanks in advance.

Have a good day.

@martykube
Copy link
Contributor Author

@ffbit Thanks for the positive feedback! I'll keep an eye out for comments/questions.suggestions.

I am sorry to say I don't have any recommendations yet on TestNG reading. This is my first encounter with TestNG... I was asked to add Cucumber to an existing Selenium framework. The framework uses TestNG so here I am :-)

I do want to add a some code examples, maybe at examples/java-calculator-testng/README.md. That might make it easier for folks to pick up Cucumber + TestNG.

@@ -17,28 +17,10 @@
import java.io.IOException;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some unused imports left. Could you please remove them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

@ffbit
Copy link
Contributor

ffbit commented Nov 8, 2013

@martykube great job, yet again!
I'm looking forward to you changes or reasons not to do them.
Have a nice day.

// remove duplicates from glue path.
List<String> uniqueGlue = new ArrayList<String>(new HashSet<String>(runtimeOptions.getGlue()));
runtimeOptions.getGlue().clear();
runtimeOptions.getGlue().addAll(uniqueGlue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martykube I reckon that you got trouble when the glue paths was not unique. Maybe it would be better if the RuntimeOptions itself should make sure that the glue paths were unique. I don't say that this should be done in this pull request, but it is something that maybe should be done as an improvement later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brasmusson Uniqueness of glue paths is provided by line 37.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ffbit Now I do not follow. I can see that line 37-39 makes the glue paths unique. The thing is that one part of me says that that code does not belong here, because uniques of glue paths is not something that is important just for a TestNG runner, is it? But if it is important that the glue paths are unique (regardless of running from command line, using the JUnit runner, using the TestNG runner, etc), shouldn't it be the RuntimeOptions class responsibility to make sure that the glue paths are unique?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brasmusson I totally agree with you.
I think we should go much deeper to provide uniqueness of discovered classes with step definitions.
And, as you mentioned, there should be another PR on this problem.

@brasmusson thanks for your finding and I'm sorry for my bad previous comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to summarise my view on the code in lines 37-39.
It's a hack, but it's a forced one. Let's let it go and fix its roots later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trouble I had was that RuntimeOptions created duplicate entries due to the test class and the super class being in the same package. Then the test case failed due to duplicate step definitions being found during the second scan of the duplicate glue path.

I agree that this should be pushed down into RuntimeOptions.

This pull request needs the duplicate elimination. We could either 1) fix RuntimeOptions and remove the code in this pull request, or 2) Leave this patch as is and add duplicate elimination to RuntimeOptions in another pull request. Let me know what makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second option is good in my view.

@martykube
Copy link
Contributor Author

@ffbit Your suggestions are good, I'll make the changes.
Two comments were for empty line removal - I'm not sure which line is the offender. Let me know, Thanks!

@ffbit
Copy link
Contributor

ffbit commented Nov 10, 2013

@martykube I've just sent you a pull request with those empty lines removed. Please check it out in your own forked repo.

@martykube
Copy link
Contributor Author

@ffibit got the pull for the empty lines. I'm working on the other comments and should have that finished shortly

@ffbit
Copy link
Contributor

ffbit commented Nov 11, 2013

You can merge my commit and it will appear in this thread, if you want.
Just to clarify, please do not implement glue merging in this PR - it's out of scope.

11.11.2013, 23:54, "Marty Kube" notifications@github.com:

@ffibit got the pull for the empty lines. I'm working on the other comments and should have that finished shortly


Reply to this email directly or view it on GitHub.

@martykube
Copy link
Contributor Author

@ffibit I've added a commit to address the comments. Let me know if there is anything else needed to allow a merge.

I was thinking about updating RuntimeOptions to make the glue paths unique.

@martykube
Copy link
Contributor Author

@ffbit Your commit is in. No glue merging here :-)

I'm "hands off" on this pull request unless there are other comments,

ffbit pushed a commit that referenced this pull request Nov 12, 2013
Allow TestNG Cucumber runner to use composition instead of inheritance
@ffbit ffbit merged commit cca52ae into cucumber:master Nov 12, 2013
@ffbit
Copy link
Contributor

ffbit commented Nov 12, 2013

@martykube
Great job!

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot unassigned ffbit Oct 25, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
@aslakhellesoy
Copy link
Contributor

Hi @martykube,

Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾

In return for this generous offer we hope you will:

  • ✅ Continue to use branches and pull requests. When someone on the core team approves a pull request (yours or someone else's), you're welcome to merge it yourself.
  • 💚 Commit to setting a good example by following and upholding our code of conduct in your interactions with other collaborators and users.
  • 💬 Join the community Slack channel to meet the rest of the team and make yourself at home.
  • ℹ️ Don't feel obliged to help, just do what you can if you have the time and the energy.
  • 🙋 Ask if you need anything. We're looking for feedback about how to make the project more welcoming, so please tell us!

On behalf of the Cucumber core team,
Aslak Hellesøy
Creator of Cucumber

1 similar comment
@aslakhellesoy
Copy link
Contributor

Hi @martykube,

Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾

In return for this generous offer we hope you will:

  • ✅ Continue to use branches and pull requests. When someone on the core team approves a pull request (yours or someone else's), you're welcome to merge it yourself.
  • 💚 Commit to setting a good example by following and upholding our code of conduct in your interactions with other collaborators and users.
  • 💬 Join the community Slack channel to meet the rest of the team and make yourself at home.
  • ℹ️ Don't feel obliged to help, just do what you can if you have the time and the energy.
  • 🙋 Ask if you need anything. We're looking for feedback about how to make the project more welcoming, so please tell us!

On behalf of the Cucumber core team,
Aslak Hellesøy
Creator of Cucumber

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

Successfully merging this pull request may close these issues.

4 participants