mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-22 07:53:34 +01:00
adding request-level error reporting
This commit is contained in:
parent
882341c35b
commit
de530a889c
@ -174,7 +174,7 @@ const makeJunitOutput = async (results, outputPath) => {
|
||||
}
|
||||
};
|
||||
|
||||
results.forEach((result, idx) => {
|
||||
results.forEach((result) => {
|
||||
const assertionTestCount = result.assertionResults ? result.assertionResults.length : 0;
|
||||
const testCount = result.testResults ? result.testResults.length : 0;
|
||||
const totalTests = assertionTestCount + testCount;
|
||||
@ -212,7 +212,6 @@ const makeJunitOutput = async (results, outputPath) => {
|
||||
result.testResults &&
|
||||
result.testResults.forEach((test) => {
|
||||
const testcase = {
|
||||
'@type': 'testcase',
|
||||
'@name': test.description,
|
||||
'@status': test.status,
|
||||
'@classname': result.request.url,
|
||||
@ -228,6 +227,20 @@ const makeJunitOutput = async (results, outputPath) => {
|
||||
suite.testcase.push(testcase);
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
suite['@errors'] = 1;
|
||||
suite['@tests'] = 1;
|
||||
suite.testcase = [
|
||||
{
|
||||
'@name': 'Test suite has no errors',
|
||||
'@status': 'fail',
|
||||
'@classname': result.request.url,
|
||||
'@time': result.runtime.toFixed(3),
|
||||
error: [{ '@type': 'error', '@message': result.error }]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
output.testsuites.testsuite.push(suite);
|
||||
});
|
||||
|
||||
|
@ -157,4 +157,43 @@ describe('makeJUnitOutput', () => {
|
||||
expect(failcase.failure).toBeDefined;
|
||||
expect(failcase.failure[0]['@type']).toBe('failure');
|
||||
});
|
||||
|
||||
it('should handle request errors', () => {
|
||||
const results = [
|
||||
{
|
||||
description: 'description provided',
|
||||
suitename: 'Tests/Suite A',
|
||||
request: {
|
||||
method: 'GET',
|
||||
url: 'https://ima.test'
|
||||
},
|
||||
assertionResults: [
|
||||
{
|
||||
lhsExpr: 'res.status',
|
||||
rhsExpr: 'eq 200',
|
||||
status: 'fail'
|
||||
}
|
||||
],
|
||||
runtime: 1.2345678,
|
||||
error: 'timeout of 2000ms exceeded'
|
||||
}
|
||||
];
|
||||
|
||||
makeJunitOutput(results, '/tmp/testfile.xml');
|
||||
|
||||
const junit = xmlbuilder.create.mock.calls[0][0];
|
||||
|
||||
expect(createStub).toBeCalled;
|
||||
|
||||
expect(junit.testsuites).toBeDefined;
|
||||
expect(junit.testsuites.testsuite.length).toBe(1);
|
||||
expect(junit.testsuites.testsuite[0].testcase.length).toBe(1);
|
||||
|
||||
const failcase = junit.testsuites.testsuite[0].testcase[0];
|
||||
|
||||
expect(failcase['@name']).toBe('Test suite has no errors');
|
||||
expect(failcase.error).toBeDefined;
|
||||
expect(failcase.error[0]['@type']).toBe('error');
|
||||
expect(failcase.error[0]['@message']).toBe('timeout of 2000ms exceeded');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user