apache / apache/maven-surefire
[SUREFIRE-1984] To be able to kill a fork as soon as a test case fails and start a new fork from the failed testcase, following which subsequent testcases are run.
- Dominant language
- Java
- Stars
- 461
- Forks
- 588
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 19
Description
**[Rishabh Arora](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=JIRAUSER284083)** opened **[SUREFIRE-1984](https://issues.apache.org/jira/browse/SUREFIRE-1984?redirect=false)** and commented
I need this feature because some testcases need isolated environment to run. I have seen that certain testcases fail on an existing fork but seem to run fine on a new fork. I want to be able to keep the number of active forks same at all times. Just that kill the fork that executes a failed testcase and retry on a newly generated fork.
The idea in a nutshell:
---
```java
import org.junit.Assert;
import org.junit.Test;
public class surefireTest {
private static boolean flag = true;
@Test
public void test1() {
Assert.assertTrue(flag);
flag = false;
}
@Test
public void test2() {
test1();
}
@Test
public void test3() {
test1();
}
}
```
---
Running the above code using surefire using \1\ & \3\ should ideally be able to pass all the testcases, but in our case it is able to pass just testcase 1. Is it possible to have a completely isolated environment (free from pollution from other testcases) for all 3 testcases, that is as soon as a testcase fails, we kill the current fork and start a new fork and retry for the failed testcase and so on.
Please find the observed result attached below.
Thanks!
---
**Attachments:**
- [Screenshot 2022-01-25 at 10.36.34 AM.png](https://issues.apache.org/jira/secure/attachment/13039311/Screenshot+2022-01-25+at+10.36.34+AM.png) (_28.42 kB_)
Contributor guide
Research direction
Start by tracing how Surefire handles and , using the provided JUnit example as the reproduction case. Determine where a failed testcase is retried and where fork lifecycle is managed. Done means a failed testcase can trigger a replacement fork, retry in isolation, and allow subsequent testcases to run while maintaining the configured number of active forks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100