Search code examples
karate

How can I programmatically determine the pass percentage for karate features/scenarios after running a test suite?


In our CI/CD pipeline setup using GitLab, how can I automate the process of assessing the pass percentage of Karate features/scenarios/tests following the execution of a test suite? This assessment is crucial for making decisions regarding whether to proceed with subsequent stages of the pipeline, such as deployment.


Solution

  • Normally teams expect all 100% tests to pass else the build fails, and that's how it works today, example below.

        Results results = Runner.path("classpath:").parallel(5);
        assertEquals(0, results.getFailCount(), results.getErrorMessages());
    

    Java teams can use the same Runner API and call more methods on the Results object to get total passed and total failed scenarios etc. The rest is up to you and typically JUnit.