0

run only fail test but after all build work This is my fail test case

ExempleIT extends BaseIT {
    @Test
    public void testfailure(){
            Assertions.assertTrue(false);
    }

and this is my base test class

@ExtendWith({SpringExtension.class})
@SpringBootTest()
public abstract class BaseIT { ...
  1. I tried

    maven -Dfailsafe.skipAfterFailureCount=1 -Dfailsafe.rerunFailingTestsCount=2
    

    and surefire but these does not support junit5

  2. I rerunner-jupiter but this supports only method base but I want to use base class for all tests and after all build, Which other way can I follow?

Bashir
  • 2,057
  • 5
  • 19
  • 44
butd
  • 1
  • 1

1 Answers1

0

Check this answer.

The maven-surefire-plugin, as of today, does not have full support of JUnit 5. There is an open issue about adding this support in SUREFIRE-1206.

As such, you need to use a custom provider.(...)

This info is from an old post.

The existing limitation with maven-surefire is related only with some features on JUNIT5.

Community
  • 1
  • 1
nandilov
  • 699
  • 8
  • 18
  • but I want run integration test, I know surefire is for unit test. Am I right? @nandilov – butd Apr 28 '20 at 15:42
  • Can you explain what is not supported in Maven Surefire cause the issue you are referencing is closed a long time ago apart from that I don't see any missing feature for JUnit 5 ?...I'm using JUnit 5 with surefire/failsafe for more than two years?... – khmarbaise Apr 28 '20 at 16:45
  • @khmarbaise it is compatible, BUT the option "skip after failure count" it is not available at all on JUNIT5, and there is a limitation on "re-run count" - [check here](https://maven.apache.org/surefire/maven-surefire-plugin/featurematrix.html). – nandilov Apr 28 '20 at 17:50
  • @butd you are using junit - unit testing framework. – nandilov Apr 28 '20 at 17:52
  • 1
    Rerun is available sind 3.0.0-M4 ...JUnit Jupiter and JUnit 3/4/TestNG are completely different things..they are working different and have different features where I prefer JUnit Jupiter for several reasons...Skip after failure sounds like Repeated test https://junit.org/junit5/docs/current/user-guide/#writing-tests-repeated-tests which means JUnit Jupiter supports that already. – khmarbaise Apr 28 '20 at 18:04
  • I don't think repeat is a similar behaviour, because it seems that it will always repeat the test right? Skip after failure is different because the test will end with skipped result and with the repeated, if the last fails, we do not ensure that. It is more similar with retry, but it is also different because with surefire options it only retries if it fails. Also, a main difference is that you need to change code, with surefire plugin options you can use it or not on your pom config or maven cmd options(in this case no need to change code/config files). – nandilov Apr 28 '20 at 18:18
  • Take a look at: JUnit Jupiter extension .. https://junit-pioneer.org/docs/repeat-failed-test/ – khmarbaise Apr 29 '20 at 21:08
  • The test report of the rerun can be lost using the annotation RepeatFailedTest. If they are not lost, how you want to distinguish between them in the XML/HTML report? – tibor17 Apr 30 '20 at 01:41
  • `skipAfterFailureCount` skips the rest of classes if a test has ended by failure/error. The `rerun` also has the end but it works with individual classes. On the ither hand the `skipAfterFailureCount` counts the failures in whole test-set. – tibor17 Apr 30 '20 at 01:42