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

Adding support for JavaScript String interpolation in Scenario Names a… #1416

Conversation

joelpramos
Copy link
Contributor

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.

@joelpramos joelpramos changed the title Adding support for JavScript String interpolation in Scenario Names a… Adding support for JavaScript String interpolation in Scenario Names a… Dec 28, 2020
}
}

public void evaluateScenarioDescription() {
Copy link
Member

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 :|

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor Author

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

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 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) {
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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

@ptrthomas
Copy link
Member

thanks for the detailed PR with tests 👍
apologies that I was in the middle of a refactoring that will impact your PR / constructor of ScenarioRuntime hope it is not too much trouble

@joelpramos
Copy link
Contributor Author

thanks for the detailed PR with tests 👍
apologies that I was in the middle of a refactoring that will impact your PR / constructor of ScenarioRuntime hope it is not too much trouble

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.

ptrthomas added a commit that referenced this pull request Dec 30, 2020
@ptrthomas
Copy link
Member

@joelpramos added my comments, no hurry

…nterpolation-scenario-name-#1413

# Conflicts:
#	karate-core/src/main/java/com/intuit/karate/core/ScenarioRuntime.java
Copy link
Contributor Author

@joelpramos joelpramos left a 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() {
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 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

@joelpramos joelpramos requested a review from ptrthomas January 2, 2021 17:36
@joelpramos
Copy link
Contributor Author

Updated #1373 (comment)

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

Successfully merging this pull request may close these issues.

2 participants