[FIXED JENKINS-36336] Always show fixed tests if there are some (#373)

* JENKINS-36336 Always show fixed tests if there are some
* JENKINS-36930 Test results display not handling REGRESSION case
This commit is contained in:
Keith Zantow 2016-07-27 11:59:16 -04:00 committed by GitHub
parent b8c038abac
commit 91c4188539
2 changed files with 52 additions and 14 deletions

View File

@ -32,6 +32,7 @@ const TestCaseResultRow = (props) => {
let statusIndicator = null;
switch (t.status) {
case 'REGRESSION':
case 'FAILED':
statusIndicator = StatusIndicator.validResultValues.failure;
break;
@ -67,12 +68,11 @@ export default class TestResult extends Component {
const suites = this.props.testResults.suites;
const tests = [].concat.apply([], suites.map(t => t.cases));
// possible statuses: PASSED, FAILED, SKIPPED
const failures = tests.filter(t => t.status === 'FAILED');
// one of 5 possible statuses: PASSED, FIXED, SKIPPED, FAILED, REGRESSION see: hudson.tasks.junit.CaseResult$Status :(
const fixed = tests.filter(t => t.status === 'FIXED');
const skipped = tests.filter(t => t.status === 'SKIPPED');
const newFailures = failures.filter(t => t.age === 1);
const existingFailures = failures.filter(t => t.age > 1);
const newFailures = tests.filter(t => (t.age <= 1 && t.status === 'FAILED') || t.status === 'REGRESSION');
const existingFailures = tests.filter(t => t.age > 1 && t.status === 'FAILED');
let passBlock = null;
let newFailureBlock = null;
@ -129,13 +129,6 @@ export default class TestResult extends Component {
</div>);
}
if (fixed.length > 0) {
fixedBlock = (<div className="test-result-block fixed-block">
<h4>Fixed</h4>
{fixed.map((t, i) => <TestCaseResultRow key={i} testCase={t} />)}
</div>);
}
if (skipped.length > 0) {
skippedBlock = (<div className="test-result-block skipped-block">
<h4>Skipped - {skipped.length}</h4>
@ -144,14 +137,22 @@ export default class TestResult extends Component {
}
}
// always show fixed, whether showing totals or the encouraging message
if (fixed.length > 0) {
fixedBlock = (<div className="test-result-block fixed-block">
<h4>Fixed</h4>
{fixed.map((t, i) => <TestCaseResultRow key={i} testCase={t} />)}
</div>);
}
return (
<div>
{passBlock}
{summaryBlock}
{newFailureBlock}
{existingFailureBlock}
{fixedBlock}
{skippedBlock}
{passBlock}
</div>
);
}

View File

@ -62,6 +62,25 @@ describe("TestResults", () => {
assert.equal(newFailed, 1);
});
it("Handles REGRESSION case", () => {
var failures = {
"_class":"hudson.tasks.junit.TestResult",
"duration":0.008, "empty":false, "failCount":3, "passCount":0, "skipCount":0, "suites":[
{ "duration":0, "id":null, "name":"failure.TestThisWontFail", "stderr":null, "stdout":null, "timestamp":null, "cases": [
{"age":5,"className":"failure.TestThisWontFail","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest2","skipped":false,"skippedMessage":null,"status":"FAILED","stderr":null,"stdout":null},
{"age":2,"className":"failure.TestThisWontFail","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest3","skipped":false,"skippedMessage":null,"status":"REGRESSION","stderr":null,"stdout":null},
{"age":1,"className":"failure.TestThisWontFail","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest4","skipped":false,"skippedMessage":null,"status":"FAILED","stderr":null,"stdout":null},
],
}]};
let wrapper = shallow(<TestResults testResults={failures} />);
const newFailed = wrapper.find('.new-failure-block h4').text();
assert.equal(newFailed, 'New failing - 2');
const failed = wrapper.find('.existing-failure-block h4').text();
assert.equal(failed, 'Existing failures - 1');
});
it("All passing shown", () => {
let wrapper = shallow(<TestResults testResults={testResults1} />);
let isDone = wrapper.html().indexOf('done_all') > 0;
@ -78,7 +97,25 @@ describe("TestResults", () => {
}]};
wrapper = shallow(<TestResults testResults={success} />);
isDone = wrapper.html().indexOf('done_all') > 0;
assert(isDone, "Done all not found, when should be");
let html = wrapper.html();
assert(html.indexOf('done_all') > 0, "Done all not found, when should be");
assert(html.indexOf('fixed-block') < 0, "No fixed tests!");
});
it("All passing and fixed shown", () => {
var successWithFixed = {
"_class":"hudson.tasks.junit.TestResult",
"duration":0.008, "empty":false, "failCount":0, "passCount":3, "skipCount":0, "suites":[
{ "duration":0, "id":null, "name":"failure.TestThisWontFail", "stderr":null, "stdout":null, "timestamp":null, "cases": [
{"age":0,"className":"failure.TestThisWontFail","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest2","skipped":false,"skippedMessage":null,"status":"FIXED","stderr":null,"stdout":null},
{"age":0,"className":"failure.TestThisWontFail","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest3","skipped":false,"skippedMessage":null,"status":"PASSED","stderr":null,"stdout":null},
{"age":0,"className":"failure.TestThisWontFail","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest4","skipped":false,"skippedMessage":null,"status":"PASSED","stderr":null,"stdout":null},
],
}]};
let wrapper = shallow(<TestResults testResults={successWithFixed} />);
let html = wrapper.html();
assert(html.indexOf('done_all') > 0, "Done all not found, when should be");
assert(html.indexOf('fixed-block') > 0, "Should have fixed tests!");
});
});