Closed jayanthktn closed 6 years ago
While this isn't possible in the default reporter, setting percentage reports up using a custom reporter is quite straightforward, as can be seen below.
You can start off by checking out our docs for custom Newman reporters here: https://www.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman#custom-reporters
Next, you can build on top of the existing HTML reporter to add your own helper for percentage calculations. This can be done by including the following snippet in your custom reporter code:
handlebars.registerHelper('percent', function (passed, failed) {
return (passed * 100 / (passed + failed)).toFixed(2);
});
Now, you can use compute percent values anywhere in your report by including the following statement in the handlebars template:
{{percent cumulativeTests.passed cumulativeTests.failed}}
Note that the javascript code for your custom reporter will have to reference the path to your modified handlebars template.
Feel free to revert if you have any questions 😄
I am getting the following error .
\helper-missing.js:19 throw new _exception2['default']('Missing helper: "' + arguments[arguments.length - 1].name + '"'); ^ Error: Missing helper: "percent"
Here's my main code,
***
Postman for Windows Version 5.3.2 Win 7 / x64 Newman 3.9.3
My request is to display the pass percentage in the console log - Much easier for management people. Additionally adding percentage of passed Test cases . 79 passed out of 93 means = 84.94%..
Something like that.