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

[CENT-366] Fine-tune when to print missing unit tests #232

Merged
merged 1 commit into from
Oct 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions verification/verification_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ const jsdiff = require('diff');
const colors = require('colors');

// Global variables for text output.
const green_x = color('bright pass', base_reporter.symbols.err);
const red_x = color('bright fail', base_reporter.symbols.err);
const green_ok = color('bright pass', base_reporter.symbols.ok);
const green_ok = color('green', base_reporter.symbols.ok);
const red_ok = color('bright fail', base_reporter.symbols.ok);
const indent = ' ';

Expand Down Expand Up @@ -111,15 +110,15 @@ function verification_reporter (runner) {

// If test is marked pending in spreadsheet, record for later output.
if(spreadsheet_test.pending) {
console.log(indent + green_x + color('bright pass', ' pending'));
console.log(indent + green_ok + color('green', ' pending'));
if(! pending[suite]) {
pending[suite] = {};
}
pending[suite][id] = test_ran;

// If test descriptions match, mark green.
} else if (spreadsheet_test.description == test_ran) {
console.log(indent + green_x);
console.log(indent + green_ok);

// If test is in spreadsheet, but descriptions don't match.
} else {
Expand Down Expand Up @@ -172,7 +171,7 @@ function verification_reporter (runner) {
console.log('\n\nSpreadsheet Verification Summary:\n');
// If there are pending tests included in the test suite...
if (!_.isEmpty(pending)) {
console.log(color('bright pass', 'Pending Tests:'));
console.log(color('green', 'Pending Tests:'));
console.log('The following tests are included in the test suite, but\n'
+ 'marked pending in the spreadsheet (delete -p flag once merged): ');
console.log(util.inspect(pending, { showHidden: false, depth: null }));
Expand All @@ -191,17 +190,29 @@ function verification_reporter (runner) {
}
}

// Do not report missing unit tests for files that did not run
// Report missing unit tests for files that were executed
for(var testSuite in missingUnitTests){
if(! _.has(executedTestSuites, testSuite) /* && ! testSuite.match(/Completeness/)*/) {
if(! _.has(executedTestSuites, testSuite)) {
console.log(color('fail', 'Did not run: ' + testSuite));
delete missingUnitTests[testSuite];
}
}

// report missing Completeness unit tests ONLY if every test file ran
var onlyCompletenessTestsAreMissing = true;
for(var testSuite in missingUnitTests){
if(! testSuite.match(/Completeness/))
onlyCompletenessTestsAreMissing = false;
}
if(onlyCompletenessTestsAreMissing){
for(var testSuite in missingUnitTests){
console.log(color('fail', 'Did not run: ' + testSuite));
}
}

// If all tests are 'crossed-off', print success.
if (_.isEmpty(missingUnitTests)) {
console.log('\n' + green_ok + color('bright pass',
console.log('\n' + green_ok + color('green',
' Test run contains all tests in spreadsheet.'));
} else {
// If not all tests are 'crossed-off', print the tests remaining.
Expand Down