1

I would like to understand how the com.intuit.karate.RuntimeHook class behaves when the methods are overwritten. I did the following

public class MyHook implements RuntimeHook {
 @Override
  public void beforeSuite(Suite suite){
    
    Runner.runFeature("call my feature", null, true);
  
  }

  @Override
  public void afterSuite(Suite suite) {
    Runner.runFeature("call another feature", null, true);

  } 
}

After I called this class: MyHook from my Runner Class: Inside my Runner class I have this method

 @Test
    void testParallel() { 
        Results results = Runner.path("my classpath")
                .hook(new MyHook())
                .parallel(1);
        assertEquals(0, results.getFailCount(), results.getErrorMessages());
    }

When I run my test Suite the methods** beforeSuite and afterSuite are called twice.** Why this is happening? If I remove the call of the class: MyHook from my Runner the methods are called just once. My intention with this class is to run a set of data before my tests and clean the data after all the tests are finished.

arhadoop
  • 11
  • 2
  • indeed possible that there is a bug in karate. only way to be sure is if you follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue - and we welcome code contributions. that said, if you are just concerned with before and after the suite, why don't you just do it in the `testParallel()` block: https://stackoverflow.com/a/60944060/143475 – Peter Thomas Mar 22 '23 at 15:01

0 Answers0