[ 
https://issues.apache.org/jira/browse/SUREFIRE-1984?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rishabh Arora updated SUREFIRE-1984:
------------------------------------
    Description: 
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:

----

{code: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();
    }
}
{code}

----

Running the above code using surefire using <forkCount>1</forkCount> & 
<rerunFailingTestsCount>3</rerunFailingTestsCount> 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!
 

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

----

{code: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();
    }
}
{code}

----

Running the above code using surefire 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?

Please find the observed result attached below.
Thanks!
 


> 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. 
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-1984
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1984
>             Project: Maven Surefire
>          Issue Type: Wish
>          Components: process forking
>            Reporter: Rishabh Arora
>            Priority: Major
>             Fix For: Backlog
>
>         Attachments: Screenshot 2022-01-25 at 10.36.34 AM.png
>
>
> 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:
> ----
> {code: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();
>     }
> }
> {code}
> ----
> Running the above code using surefire using <forkCount>1</forkCount> & 
> <rerunFailingTestsCount>3</rerunFailingTestsCount> 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!
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to