Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Karate Stats/Results Output to a seperate when using the jar #561

Closed
jawadkalia opened this issue Oct 17, 2018 · 4 comments
Closed

Get Karate Stats/Results Output to a seperate when using the jar #561

jawadkalia opened this issue Oct 17, 2018 · 4 comments
Assignees

Comments

@jawadkalia
Copy link

Is this an issue or a feature request?
Feature Request

Expected Outcome

A new console arg for the jar which will output the karateStats/Results to an html/text file

Example use case scenario
java -jar karate.jar --stats= "./Stats.html"
HTML code that might help

<html>
<style>
    td {
        border: 1px solid black;
        height: 50px;
        vertical-align: bottom;
    }
</style>
<div>
    <p style="color: blue">
        Elapsed Time: 10.58
    </p>
    <p style="color:blue">
        Total Thread Time: 31.58
    </p>
    <table style="border-collapse: collapse; border: 1px solid black; width: 50%">

        <tr>
            <td>
                Features: 9</td>
            <td>
                Threads: 5</td>
            <td>
                Efficiency: 0.60</td>
        </tr>
        <tr>
            <td>
                Scenarios: 46</td>
            <td>
                Failed: 0</td>
            <td>
                Skipped: 0</td>
        </tr>

    </table>

</div>

</html>

@jawadkalia
Copy link
Author

sample java code i wrote for maven

 private static void statstoText(KarateStats stats) throws IOException {
        FileWriter fileWriter = new FileWriter("./STATS.html");
        PrintWriter printWriter = new PrintWriter(fileWriter);
        printWriter.printf("<h2>Karate Stats</h2>");
        printWriter.printf("<p>Total Run count was %d</p>", stats.getTestCount());
        printWriter.printf("<p>Total Failed count was %d</p>", stats.getFailCount());
        printWriter.printf("<p>Total Feature count was %d</p>", stats.getFeatureCount());
        printWriter.close();
    }

@ptrthomas ptrthomas self-assigned this Oct 17, 2018
@ptrthomas ptrthomas added this to the 0.9.0 milestone Oct 17, 2018
@ptrthomas
Copy link
Member

@Drk46 I decided to output a JSON file instead so that users can re-format as they wish and it is a little future proof. so a results.json will be output as follows into the output dir (default target)

{
   "features":56,
   "ignored":25,
   "efficiency":0.4935214060170045,
   "failures":null,
   "totalTime":7545.942297999999,
   "threads":5,
   "scenarios":154,
   "failed":0,
   "passed":154,
   "version":"0.9.0",
   "elapsedTime":3058.0
}

would be great if you build from source and try out

@ptrthomas
Copy link
Member

@Drk46 made one change because any extra *.json file would mess up the cucumber reporter !
so the file would default to results-json.txt

@ptrthomas
Copy link
Member

0.9.0 released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants