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

Is it possible to get content in describe block alone in reports? #92

Open
SwathiJayabharathi opened this issue Sep 10, 2018 · 3 comments
Labels

Comments

@SwathiJayabharathi
Copy link

i need a summary of test execution. i am trying to get content present in describe block in all the suites and print in reports.
Eg: i am executing 25 spec files at a time. my report provides both suite and testcase status. But i want one summary stating whether the particular suite passed or failed.

first_spec.js
describe('Suite1', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');

expect(browser.getTitle()).toEqual('Super Calculator');

});
});

second_spec.js
describe('Suite2', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');

expect(browser.getTitle()).toEqual('Super Calculator');

});
});

third_spec.js
describe('Suite3', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');

expect(browser.getTitle()).toEqual('Super Calculator');

});
});

Report.html should be

Suites Status
Suite1 Pass
suite2 Pass
Suite3 Fail

Is that possible in protractor-beautiful-reporter?

@miller45
Copy link
Collaborator

miller45 commented Sep 10, 2018

@SwathiJayabharathi protractor-beautiful-reporter cannot do that out of box.
But you can add an additional reporter like JUnitXmlReporter to protractor.conf like this:
jasmine.getEnv().addReporter(new jr.JUnitXmlReporter({ savePath: 'e2ereports', consolidateAll: false }));
The resulting xml file has then the data you need (for example it looks like this):
<?xml version="1.0" encoding="UTF-8" ?> <testsuites disabled="2" errors="0" failures="2" tests="19" time="48.611"> <testsuite name="angularjs homepage" timestamp="2018-09-10T21:24:38" hostname="localhost" time="21.344" errors="0" tests="3" skipped="0" disabled="0" failures="2"> <testcase classname="angularjs homepage" name="should fail as greeting text is different" time="4.8"> <failure type="toEqual" message="Expected &apos;Hello Julie!&apos; to equal &apos;Hello Julie hello!&apos;."> </failure> </testcase> <testcase classname="angularjs homepage" name="should greet the named user" time="1.765" /> <testcase classname="angularjs homepage" name="should contain log and pretty stack trace" time="1.052"> <failure type="exception" > </failure> </testcase> </testsuite> </testsuites>

@SwathiJayabharathi
Copy link
Author

if we use JUnitXmlReporter, it will display testcase name too. but here I want only test Suite details.
is there any options to set for displaying testSuite details alone?

@miller45
Copy link
Collaborator

miller45 commented Sep 13, 2018

@SwathiJayabharathi
Install "filterxml" package via npm an execute a script like this:

var fs = require('fs');
var path = require('path');
var filterxml = require('filterxml');

var baseDir = path.resolve(__dirname, "./reports-tmp/"); // change to your path with xml files
var files = fs.readdirSync(baseDir).filter(function (f) {
    return f.endsWith(".xml");
});

var output = "";
files.forEach(function (file) {
    var xmlIn = fs.readFileSync(path.join(baseDir, file)).toString();
    var output = "";
    filterxml(xmlIn, ['//testcase'], {}, function (err, xmlOut) {
        output += xmlOut + "\n";
    });
    var outFile = path.join(baseDir, path.basename(file,".xml") + "-suite-only.xml");
    fs.writeFileSync(outFile,output);
    console.log(output);
});

After that for each xml file the will antother one with "-suite-only.xml" that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites disabled="0" errors="0" failures="0" tests="47" time="17.166">
 <testsuite name="second top level" timestamp="2018-09-10T21:25:00" hostname="localhost" time="4.305" errors="0" tests="1" skipped="0" disabled="0" failures="0">
 </testsuite>
 <testsuite name="second top level.nested deeply spec level 1" timestamp="2018-09-10T21:25:01" hostname="localhost" time="3.448" errors="0" tests="2" skipped="0" disabled="0" failures="0">
 </testsuite>
 <testsuite name="second top level.nested deeply spec level 1.nested deeply spec level 2" timestamp="2018-09-10T21:25:01" hostname="localhost" time="3.282" errors="0" tests="2" skipped="0" disabled="0" failures="0">
 </testsuite>
 <testsuite name="second top level.nested deeply spec level 1.nested deeply spec level 2.nested deeply spec level 3" timestamp="2018-09-10T21:25:01" hostname="localhost" time="3.138" errors="0" tests="2" skipped="0" disabled="0" failures="0">
 </testsuite>
 <testsuite name="second top level.nested deeply spec level 1.nested deeply spec level 2.nested deeply spec level 3.nested deeply spec level 4" timestamp="2018-09-10T21:25:01" hostname="localhost" time="2.993" errors="0" tests="40" skipped="0" disabled="0" failures="0">
 </testsuite>
</testsuites>

@miller45 miller45 added support and removed question labels Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants