-
-
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
Adding support for JavaScript String interpolation in Scenario Names a… #1416
Adding support for JavaScript String interpolation in Scenario Names a… #1416
Conversation
} | ||
} | ||
|
||
public void evaluateScenarioDescription() { |
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.
- is fixing the description really necessary (then I have to include this in the JSON when we serialize a test result)
- is supporting the
\
to spill over 2 lines really necessary
I'd like to keep it simple :|
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.
what I meant when I said we need to care about multiple lines is I believe the first line always goes into the name
and any extra lines go into the description
. if that is the case, I propose we only interpolate the name
for those who want extra / dynamic docs - the new doc
keyword is what I'd like users to use, and this can go into any Step
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.
when I thought about 2 lines I was thinking about wrapping lines - different developers might have different views in terms of the size of a line / line wrap. I agree that anything past 2 lines is probably bad practice (and reports won't look pretty at all) but what do you think about still supporting any lines and leaving the "good practice" of keeping the name short and simple to the test scripters?
I'm just thinking that might need to throw an exception if we want to limit to 2 lines and one day someone will want "just" the 3 lines :)
The description was already in the code (saw it in the replace). Are you planning on removing it all together? I agree with not evaluating as the scenario outline should always do the same validations so a static description should suffice.
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.
I hear ya. I'd be okay if this wasn't cucumber, the syntax is biased towards "one line at a time", the only way to span multiple lines is to use the triple-quotes """
so I'd really like to stick to one-line for the name. I also made this commit to verify what I was saying, that the parser already gives you the name and description separate: 77310ac
not planning to remove the description but we have now created a JSON for representing "an executed scenario" - see the toKarateJson()
methods in ScenarioResult
etc. right now I'm not including the scenario description because it can always be derived from the original feature-file.
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.
so yes, good point - if the description is already being included in the replace - we can decide to not do it anymore. and one reason is we have a new way of adding fancy descriptions in-line. the name is important to stand out in reports
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.
got it - will remove the usage of \ altogher
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 remove the option of using string interpolation in the description but for now will leave the replace on the description - can probably be marked as deprecated or something but might be important to keep it for backwards compability
this(featureRuntime, scenario, null, false); | ||
} | ||
|
||
public ScenarioRuntime(FeatureRuntime featureRuntime, Scenario scenario, boolean backgroundRuntime) { |
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.
do we need the extra boolean won't it be a property of the ScenarioRuntime
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.
When running Scenario Outlines the Background runs wrapped in a ScenarioRuntime - while when running a scenario the background section is just included in the steps. That background ScenarioRuntime doesn't have a scenario associated with thus I had a nullpointer.
I think there was a way to figure out (like null scenario maybe or something) that I can use instead of the boolean to avoid evaluating the scenario name.
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.
try scenario.isDynamic()
you can see it used elsewhere in the same file
thanks for the detailed PR with tests 👍 |
Np happy to help as I think you created an amazing tool here and I'm just doing little tweaks here and there where I noticed some use cases. Your PR doesn't seem to affect that much, once you let me know your preference for the comment on this PR I'll do the changes and update this. |
@joelpramos added my comments, no hurry |
…nterpolation-scenario-name-#1413 # Conflicts: # karate-core/src/main/java/com/intuit/karate/core/ScenarioRuntime.java
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.
PR comments addressed
} | ||
} | ||
|
||
public void evaluateScenarioDescription() { |
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 remove the option of using string interpolation in the description but for now will leave the replace on the description - can probably be marked as deprecated or something but might be important to keep it for backwards compability
Updated #1373 (comment) |
Description
Thanks for contributing this Pull Request. Make sure that you submit this Pull Request against the
develop
branch of this repository, add a brief description, and tag the relevant issue(s) and PR(s) below.