2

I'm basically attempting to run my scenarios in sequence and trying to find if there is a way to get the handle to Results in @AfterClass method.

I know that it is possible when running in parallel, but our necessity is to get a break down of all the test executed in test report which is not possible when implemented like below.

public class AllTestRunner {

   @Test
   public void testParallel() {
      Results results = Runner.parallel(1, "classpath:karate/feature");
   }
}

The issue with this approach is that test reports appear as only 1 test executed which is not expected.

Is there a way to get Results when running like below ?

@RunWith(Karate.class)
@KarateOptions(features = "classpath:karate/feature")
public class AllTestRunner {

   @AfterClass
   public void testParallel() {
       Results results = ...;
   }

}

Basically the purpose of trying to get the Results is to perform an API call if a scenario has failed, by checking result.isFailed().

Again, running tests in parallel is generating in test report like below.


    1 tests 0 failures 0 ignored 7.373s duration 100% successful 
    Tests Standard output 
    Test Duration Result 
    testParallel 7.373s passed

1 Answers1

0

No there isn't. Maybe you can explore the hooks, but be warned that the API will change slightly in 1.0 - https://stackoverflow.com/a/59080128/143475

If you have unusual needs like this, you should consider contributing code to Karate. The so called "sequential" mode is a convenience to connect with JUnit. There should not be a problem with the parallel runner, I don't understand what you mean by "only 1 test executed".

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248