-
Notifications
You must be signed in to change notification settings - Fork 254
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
Fix cucumber tests messing with tests of dependants #92
Conversation
The cucumber @after hook was messing with the tests in projects depending on this framework. Because the @after hook is run after every scenario dependants had to either overwrite the file by including a file with the same name at the same place or do something equally ugly. By tagging the hook and the only scenario included in the framework with the "@framework" tag the hook is only ran for that scenario. Thus the hook is not ran in tests in projects depending on this one while not influencing the testing in this project.
I talked to @avandeursen after one of his lectures at the TU Delft about this issue, this is the pull request I promised him. |
This solution is not complete. Disposing the launcher twice is a problem, but now there are step definitions that are available to students, such as In my opinion, we should move this Cucumber test case to the |
Tagging the hook and scenario does not prevent the students from reusing the step definitions for they are not affected by this at all. They will need to tag the scenario's/cases they implement and use their own (tagged) Moving it to Overall I think that a untagged |
This means that the In conclusion,
The problem here is two things:
The only true fix is to move this to the template and provide it as boilerplate to edit, or start using DI. |
Admittedly, I am struck by the bad design of this as well. But annotating the For specifying an alternative |
When I think about cucumber the step definitions are like lego bricks with which you build a house in the feature file. It seems logical to me that building an apartment building with these bricks requires different What you have written above seems to imply a different understanding of cucumber, if that is the case then I probably have a flawed understanding of cucumber. |
It seems to me that you have a very well understanding of Cucumber, you do however miss my point. The fact that you had to change the feature by adding the
Or:
The intention of the Imagine the following step definitions: class StepDefs {
File temporaryFolder;
@Before
public void setUp() {
temporaryFolder = createTempDir();
}
@Given("^A feature file")
public void createFile() {
writeContents(new File(temporaryFolder, "my-feature.feature"));
}
@After("bliep"
public void cleanFolder() {
deleteDirectory(temporaryFolder)
}
} If you now create a story that uses This year students should have reused the step definitions from the framework, but failed to grab the idea to use the static accessors to the game instance. This annotation suffers from the very same problem, and is potentially even more obscure to find for students. |
Thanks @bartios, @jwgmeligmeyling. I will carefully reconsider step definitions in the jpacman-framework and the jpacman-template. Using tags sounds like the way to go. Later I'll make a decision on how to proceed. Thanks again! |
I get what you mean now (I think) but his pull request was never intended to be accepted before the end of the course. It would indeed break most of the students current solutions, but it repairs a fundamental flaw in the framework as I think we both agree that there shouldn't be any untagged @avandeursen told me when I talked to him that it was unlikely that this request would be accepted before the end of the year and I forgot to explicitly state that in the pull request. Also, you say
But a step (lego brick) used in a scenario does not necessarily need to have any consequence for the |
Yes. Very much appreciated @bartios -- thanks! |
I actually do not agree that annotating Befores and Afters is a good fix, and that they should be annotated. If the step defenitions could have the same annotation, that would be a good fix. If the annotated before/after replaces/overrides another before/after - then thats useful as well. But in all other cases step definitions will be left without their state being properly initialized by their Before, or properly being cleaned up by their after. This usage is merely a workaround for a bug in Cucumber (naively invoking all before/after methods) and will introduce new difficulties to the students. For example launching a launcher that won't be dismissed. |
Lets continue the conversation at cucumber/cucumber-jvm#1005 |
Small update based on cucumber/cucumber-jvm#1005
This is however all not required, if students reuse the step definitions from the framework. They can do this by:
(For this they should not overwrite |
Thanks a lot for the extensive discussion. This has inspired the ultimate solution in #105. Thanks!!!! |
The cucumber @after hook was messing with the tests in projects depending
on this framework. Because the @after hook is run after every scenario
dependants had to either overwrite the file by including a file with the same name
at the same place or do something equally ugly.
By tagging the hook and the only scenario included in the framework with the
"@framework" tag the hook is only ran for that scenario. Thus the hook is not
ran in tests in projects depending on this one while not influencing the testing in
this project.
fixes #83