webdriverio-boneyard / wdio-cucumber-framework

A WebdriverIO v4 plugin. Adapter for Cucumber testing framework.
MIT License
77 stars 61 forks source link

fixes issues with background steps and with scenario outlines #137

Closed Rob-Meijeren closed 6 years ago

Rob-Meijeren commented 6 years ago

Hi,

I ran into issues with using background steps and scenario outlines. After checking in the issues I saw that multiple people had issues with this and since our company is trying to move to webdriverio with Cucumber I want the current test cases that we had to work.

So after checking why the errors occurred I found that in the cucumberEventListener no scenario was found when just checking on the line number as for a scenario outline the line number was the one for the example. For that I made a change in how a scenario is found as now if go over a scenario outline I check if there is an example attached to that scenario which has the line of sourceLocation as it is passed to the function. if it is anything else the check stays the same.

For the background tasks I found that the background tasks were not in the report and also the execution would stop a step too soon. to prevent that from happening I iterate over all the children of the feature (which at runtime is the background and the currently executing scenario) and simply concat the steps of these in a new array from which (as it was) we pick the correct step with the index passed. I found that what was there unnecessarily complicated actually.

When those 2 things were fixed I ran into an issue with the reporter when it tried to find the scenario at Runtime. This was because the scenario name passed would not contain the example data that is there on Runtime. e.g. we would pass "I go to google with searchterm " and in Runtime the scenario names would be "I go to google with searchterm Cucumberjs". To fix this the sourceLocation was needed to be able to find example that is being executed which is only know in the eventListener. Therefore is passed that parameter to the function in reporter.js and from there to the getUniqueIdentifier function in reporter.js. There it is checked if a scenario outline is processed and go through the examples. When the right example is found the placeholder is replaced with the correct example data. which is then returned and passed to cucumber.

jsf-clabot commented 6 years ago

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

:white_check_mark: Rob-Meijeren
:x: Meijeren


Meijeren seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.

BorisOsipov commented 6 years ago

Hi @wswebcreation. Could you please sign CLA and make improvements from @Rob-Meijeren comments?

wswebcreation commented 6 years ago

Hi @BorisOsipov

I already signed the CLA, @Rob-Meijeren still needs to do that. He is also going to fix the review comments today, so maybe a new release can be made today when the fixes are done

BorisOsipov commented 6 years ago

I already signed the CLA

Hmm bot's check says you didn't. Or your git commit's email and CLA email doesn't match.

wswebcreation commented 6 years ago

Hmm bot's check says you didn't. Or your git commit's email and CLA email doesn't match.

It's not my PR, it's the PR of @Rob-Meijeren

BorisOsipov commented 6 years ago

@wswebcreation Sorry man :) I need additional cup of coffee today morning

wswebcreation commented 6 years ago

No problem

Rob-Meijeren commented 6 years ago

@wswebcreation You asked me to write a feature file Wim but I can't find a way to try it out locally to make sure it works before I commit? Am I missing something here?

wswebcreation commented 6 years ago

Add it in the sample.feature, it should work. I also must say the test setup is a little bit complex

@BorisOsipov / @christian-bromann what would be the best approach for this?

Rob-Meijeren commented 6 years ago

@wswebcreation and @BorisOsipov The CLA was signed and the changes were made. For the test of the scenario outline I needed to modify the assertions a little bit as it has become more dynamic also for the steps the placeholder is not replaced when the e.g. test-started event is emitted.

wswebcreation commented 6 years ago

@Rob-Meijeren

I can't approve (don't have the rights), but it looks fine to me now. Tnx man, I think you helped a lot people with the fix and letting people migrate to the latest version (which rocks together with my new cucumber reporter 😜 )

@BorisOsipov / @christian-bromann

Can this be merged and if so can a new release be made (maybe also notify on Gitter / Twitter so all people can now upgrade)?

BorisOsipov commented 6 years ago

Add it in the sample.feature, it should work. I also must say the test setup is a little bit complex

I am not sure that changes in sample.feature helps us to test those problems. Did you try new version in your test projects?

The CLA was signed and the changes were made. "Meijeren seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account."

Unfortunately not full. Your commits have two different email addresses *@capgemini.com and @hotmail.nl and CLA bot complains that you must sign CLA for both commits.

Rob-Meijeren commented 6 years ago

@BorisOsipov I think the changes will help as most people will have it this way in their feature files. I can always ofcourse set the scenario outline in the current project and see if it fails. If not than you are right that it doesn't actually tests it and should be changed but I wouldn't know how to do it.

The changes I checked in my personal projects and there it fixes the issues I had with the background and scenario outlines.

Regarding the CLA. I added the capgemini mail to my github account and I see at the bottom here that the CLA a green check for signing the CLA. Could you else point me to where it says that I didn't sign it? I tried to amend the author on the capgemini commit but for some reason it didn't work and this seemed easier to do actually.

christian-bromann commented 6 years ago

wdio-cucumber-framework 2.2.1 published 🎉

BorisOsipov commented 6 years ago

The changes I checked in my personal projects and there is fixes the issues I had with the background and scenario outlines.

Awesome👍

krzywiecki commented 6 years ago

@Rob-Meijeren thanks a lot man!