-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
@martykube great job! off topic Have a good day. |
@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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
@martykube great job, yet again! |
// remove duplicates from glue path. | ||
List<String> uniqueGlue = new ArrayList<String>(new HashSet<String>(runtimeOptions.getGlue())); | ||
runtimeOptions.getGlue().clear(); | ||
runtimeOptions.getGlue().addAll(uniqueGlue); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@ffbit Your suggestions are good, I'll make the changes. |
@martykube I've just sent you a pull request with those empty lines removed. Please check it out in your own forked repo. |
@ffibit got the pull for the empty lines. I'm working on the other comments and should have that finished shortly |
You can merge my commit and it will appear in this thread, if you want. 11.11.2013, 23:54, "Marty Kube" notifications@github.com:
|
@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. |
@ffbit Your commit is in. No glue merging here :-) I'm "hands off" on this pull request unless there are other comments, |
Allow TestNG Cucumber runner to use composition instead of inheritance
@martykube |
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. |
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:
On behalf of the Cucumber core team, |
1 similar comment
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:
On behalf of the Cucumber core team, |
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.