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

the @setup hook may not be compatible with dry-run #2384

Closed
ptrthomas opened this issue Aug 24, 2023 · 12 comments
Closed

the @setup hook may not be compatible with dry-run #2384

ptrthomas opened this issue Aug 24, 2023 · 12 comments
Assignees
Milestone

Comments

@ptrthomas
Copy link
Member

as reported here: https://stackoverflow.com/q/76965130/143475

@adiChoudhary
Copy link

Hi,
I would love to work on this issue if its not already assigned.

@ptrthomas
Copy link
Member Author

@adiChoudhary sure, you can provide a summary of how you want to solve this and then submit a PR

@adiChoudhary
Copy link

Ok mate, will provide the relevant details after going through the overall project within 2-4 days of time.

@codehackerr
Copy link
Contributor

@ptrthomas can you assign this one to me, please ?

Analysis

Current code path does not execute setup steps in dry run mode.

Approach:

  • The approach will be to identify if a step is a setup step and execute it even for a dryrun.
  • Need modifications to ScenarioRuntime Scenario and Step
  • Need a test case for dynamic examples with @setup scenario

@ptrthomas
Copy link
Member Author

@codehackerr sure go ahead

@codehackerr
Copy link
Contributor

Added test cases SetupDryRunTest for feature with setup in dry run mode.

  • This error result is neither list nor function: [type: NULL, value: null] does not occur anymore.
  • Scenarios are added in the test output for each example
Test Result

@ptrthomas ptrthomas added this to the 1.5.0 milestone Jan 30, 2024
@ptrthomas
Copy link
Member Author

much appreciated @codehackerr - tagging @rc2201 as I think he reported this on stack-overflow

@ptrthomas
Copy link
Member Author

karate 1.5.0.RC3 including this fix is now available

@rc2201
Copy link

rc2201 commented Feb 2, 2024

I tested the changes and it returns the count now where @setup is being used. However full suite is being marked as failed.
This is happening for the all suites irrespective of usage of @setup. Earlier it was marked as passed.

Here are the screenshots showing everything marked as failed and confirming the release.

Dry Run Test
Dry Run Release

Error for all the scenario-
Cannot invoke "com.intuit.karate.core.Scenario.isSetup()" because "this.scenario" is null

StackTrace-
java.lang.NullPointerException: Cannot invoke "com.intuit.karate.core.Scenario.isSetup()" because "this.scenario" is null at com.intuit.karate.core.Step.isSetup(Step.java:231) at com.intuit.karate.core.ScenarioRuntime.execute(ScenarioRuntime.java:446) at com.intuit.karate.core.ScenarioRuntime.run(ScenarioRuntime.java:400) at com.intuit.karate.core.FeatureRuntime.processScenario(FeatureRuntime.java:195) at com.intuit.karate.core.FeatureRuntime$1.process(FeatureRuntime.java:142) at com.intuit.karate.core.FeatureRuntime$1.process(FeatureRuntime.java:138) at com.intuit.karate.core.ParallelProcessor.lambda$toRunnable$0(ParallelProcessor.java:59) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:840)

@ptrthomas ptrthomas removed the fixed label Feb 3, 2024
@codehackerr
Copy link
Contributor

codehackerr commented Feb 23, 2024

@rc2201 Thanks for testing this and finding the above issue!

I believe this is happening because of steps that are not under a scenario, like background. Will submit another PR.

@codehackerr
Copy link
Contributor

@rc2201 I was able to reproduce the issue with a background step and that is fixed now. Could you please verify, if the above PR fixes the issue?

@ptrthomas FYI

@ptrthomas ptrthomas added the fixed label Apr 3, 2024
@ptrthomas
Copy link
Member Author

1.5.0 released

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

No branches or pull requests

4 participants