-
Notifications
You must be signed in to change notification settings - Fork 10
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
Percentage of tests passed is rounded up #332
Comments
Happy to take a pull request for this. If some one wants to take a look, the code that calculates the percentage is here. react-components/src/components/app/ExecutionSummary.tsx Lines 48 to 51 in c27b94c
|
Including const number = parseFloat((277/278).toFixed(10));
console.log(number)
// Expected output: 0.9964028777
console.log(new Intl.NumberFormat(undefined, { style: 'percent'}).format(number));
// Expected output: "100%"
console.log(new Intl.NumberFormat(undefined, { style: 'percent', maximumSignificantDigits: 5}).format(number));
// Expected output: "99.6%" What would be the appropriate value for |
I don't think that is the right solution. Try with |
We might consider 2 decimal places but always rounding down. |
@mpkorstanje It rounds up to 100% for let number = parseFloat((0.999999999).toFixed(10));
console.log(number)
// Expected output: 0.999999999
console.log(new Intl.NumberFormat(undefined, { style: 'percent'}).format(number));
// Expected output: "100%"
console.log(new Intl.NumberFormat(undefined, { style: 'percent', maximumSignificantDigits: 5}).format(number));
// Expected output: "100%"
number = parseFloat((0.9999).toFixed(10));
console.log(number)
// Expected output: 0.9999
console.log(new Intl.NumberFormat(undefined, { style: 'percent'}).format(number));
// Expected output: "100%"
console.log(new Intl.NumberFormat(undefined, { style: 'percent', maximumSignificantDigits: 5}).format(number));
// Expected output: "99.99%" |
@mushahidq the problem that needs to be solved is that if there is 1 out of N failing tests for any positive non-zero value of N, the reported percentage should not be 100%. While you are suggesting the right solution, your example code doesn't accurately reflect that solution because you changed the input value from If you do know the right solution, please do feel free to send a pull request. Otherwise you may have to find someone else first to coach you through this. |
@mpkorstanje I apologise, I was testing using the same code segments for both cases hence the error. Someone had mentioned that rounding down to 2 decimal places might be considered so I was trying to provide an example of that where the number is round down before being passed to the formatter. Like for example using |
I would suggest to just round down instead of up, to the nearest full number. I’d imagine displaying 99% of tests passed when it’s actually 99,6% wouldn’t matter as much as displaying 100% |
In the HTML report after running a test suite, the percentage of tests passed is rounded up. This should not be happening, as it could incorrectly indicate that 100% of tests passed even though 1 of the tests failed (the percentage would be 99,6% for example).
I'm using cucumber-java version 7.3.4 and the same version of cucumber-junit
The text was updated successfully, but these errors were encountered: