-
Notifications
You must be signed in to change notification settings - Fork 52
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
How to retry Cucumber scenarios using test-retry-gradle-plugin and JUnit4 runner #276
Comments
Below error i am getting |
@hunterabhi212223 , could you try using the latest version of the plugin, i.e., |
Other than that, your configuration looks correct. |
With latest version it is working. for passed one also it is running twice. how can i run passed one 1 time and failed one twice here i am using 1.5.6 |
It should already work this way so that only failed methods are retried. But it depends on how your class is set up. For example, for parameterized methods, we will retry all iterations and not just failed ones. You need to provide a reproducer of your particular case for us to check why it is not working as expected. |
you want me to share the scenario? |
It would be best if you share your test class/method (or simplified version of it). Also, try it out on a different method and check if the plugin works as expected. Maybe this is a one of the special cases where all methods will be retried. |
I'll try to take a look at it today. We haven't seen anyone using the plugin for cucumber tests (especially with JUnit 4 runner). I'll need to check what is possible. |
is there any way that we can tell in hooks if it failed then run the gradle-retry with maxRetry = 1 |
@hunterabhi212223 , I looked into the issue today, and everything seems to work as expected. I managed to create a feature file with a passing and flaky scenario, and only the flaky scenario was re-executed. See this test for the detailed setup: https://github.com/gradle/test-retry-gradle-plugin/pull/277/files#diff-fcd808be75c92d4bdb3a7bb939cff581b01d655d67e7768e05bbea991bcba02a. I hope this will help you configure retries in your project. If I misunderstood your configuration, let me know. |
If you have multiple feature files, then also only failing scenarios from failing feature files will be retried. |
FYI: I was struggling with proposed setup for retries: The reason could be that in discovery phase (gradle) JUnit5 implementation decides that all Cucumber features, being not class and not method TestSources |
@petrandreev , let's move this discussion to a dedicated issue, since this one is about assisting @hunterabhi212223 with setting up retries for Cucumber tests using JUnit4. Here it is: #278. You are right, at the moment, the entire feature will be retried. As you said, this is a limiting factor on the Gradle side, which I am not sure we'll be able to work around in this plugin. I documented your findings + added tests for the future feature in this PR: #277. I added full Cucumber support to our roadmap, but I can't provide any schedule at the moment. |
Updated the issue title to make it easier to discover |
@pshevche Thank you for looking into the issue. I don't understand what it is written in groovy. Anyways I understood little based on that I have few questions.
If possible could please mention where to write that code part in gradle. I am completely new and learning from beginning. |
@hunterabhi212223 , no worries, let's figure it out:
At this point, you can run and retry your Cucumber scenarios using Gradle and this plugin.
As described in this documentation, any files written by Cucumber will be overwritten retrying. I haven't tested it myself, but this means that on your first run, you would have a report containing all executions (passed + failed). That report will be overwritten on the retry and contain only retried executions. Does it help? |
@pshevche public class RetryFeatureTest {
|
@hunterabhi212223 , which versions of |
cucmber-java 4.8.0 |
And |
test{ |
Aha, ok, now this makes sense. Unfortunately, retrying individual scenarios with JUnit Platform does not work at the moment. We will retry all scenarios in a feature. That's the same issue that @petrandreev mentioned above. We will look into it at #278. As for now, the plugin might not be that helpful to you. |
Any workaround for this as of know |
It works without JUnit platform, so with plain JUnit 4. If you remove |
after removing JunitPlatform() it is working fine. it is showing it is executed on default package. |
Happy to hear that! I'll consider this issue resolved in this case. Feel free to re-open if you face any other issues configuring retries for your project. |
Thank you for your support. If you find any alternate solution for junitplatform() please post here. |
I mean junitplatform () with junit 5 |
Unfortunately, no. Everything using JUnit platform will not work. Sure, will let you know once we have any updates on supporting Cucumber with JUnit platform. |
Currently on which version it is working |
Only if you use JUnit4 without JUnit platform. |
Okay thank you for info |
I am new to using gradle.I have added below in my build.gradle.
plugins {
id 'org.gradle.test-retry' version '1.0.0'
}
test {
retry {
failOnPassedAfterRetry = true
maxFailures = 3
maxRetries = 2
}
}
Here i am getting weird issue. could not run phased build action using gradle distribution gradle 7.0.1. Could not find method retry() for argument admin of type org.gradle.api
Did i missed anything to add or gradle removed test-retry
here i am unsing junit 4
Gradle 7.1
The text was updated successfully, but these errors were encountered: