Commit 724d63e8 authored by Nathan Friend's avatar Nathan Friend

Merge branch 'rw/exclude-skipped-tests-from-success' into 'master'

Exclude skipped tests in success calculation

See merge request gitlab-org/gitlab!31154
parents f6ca508c d9facbae
...@@ -29,7 +29,14 @@ export default { ...@@ -29,7 +29,14 @@ export default {
successPercentage() { successPercentage() {
// Returns a full number when the decimals equal .00. // Returns a full number when the decimals equal .00.
// Otherwise returns a float to two decimal points // Otherwise returns a float to two decimal points
return Number(((this.report.success_count / this.report.total_count) * 100 || 0).toFixed(2)); // Do not include skipped tests as part of the total when doing success calculations.
const totalCompletedCount = this.report.total_count - this.report.skipped_count;
if (totalCompletedCount > 0) {
return Number(((this.report.success_count / totalCompletedCount) * 100 || 0).toFixed(2));
}
return 0;
}, },
formattedDuration() { formattedDuration() {
return formatTime(secondsToMilliseconds(this.report.total_time)); return formatTime(secondsToMilliseconds(this.report.total_time));
......
---
title: Changed test success calculation to exclude skipped tests
merge_request: 31154
type: changed
...@@ -82,17 +82,19 @@ describe('Test reports summary', () => { ...@@ -82,17 +82,19 @@ describe('Test reports summary', () => {
describe('success percentage calculation', () => { describe('success percentage calculation', () => {
it.each` it.each`
name | successCount | totalCount | result name | successCount | totalCount | skippedCount | result
${'displays 0 when there are no tests'} | ${0} | ${0} | ${'0'} ${'displays 0 when there are no tests'} | ${0} | ${0} | ${0} | ${'0'}
${'displays whole number when possible'} | ${10} | ${50} | ${'20'} ${'displays whole number when possible'} | ${10} | ${50} | ${0} | ${'20'}
${'rounds to 0.01'} | ${1} | ${16604} | ${'0.01'} ${'excludes skipped tests from total'} | ${10} | ${50} | ${5} | ${'22.22'}
${'correctly rounds to 50'} | ${8302} | ${16604} | ${'50'} ${'rounds to 0.01'} | ${1} | ${16604} | ${0} | ${'0.01'}
${'rounds down for large close numbers'} | ${16603} | ${16604} | ${'99.99'} ${'correctly rounds to 50'} | ${8302} | ${16604} | ${0} | ${'50'}
${'correctly displays 100'} | ${16604} | ${16604} | ${'100'} ${'rounds down for large close numbers'} | ${16603} | ${16604} | ${0} | ${'99.99'}
`('$name', ({ successCount, totalCount, result }) => { ${'correctly displays 100'} | ${16604} | ${16604} | ${0} | ${'100'}
`('$name', ({ successCount, totalCount, skippedCount, result }) => {
createComponent({ createComponent({
report: { report: {
success_count: successCount, success_count: successCount,
skipped_count: skippedCount,
total_count: totalCount, total_count: totalCount,
}, },
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment