This repository has been archived by the owner on Feb 19, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78f4164
commit 667d9a7
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
(function (fs, parser, helper, path) { | ||
'use strict'; | ||
|
||
var expect = helper.chai.expect; | ||
var jacocoData = fs.readFileSync(__dirname + '/mock/jacoco.xml').toString(); | ||
var noStatsJacocoData = fs.readFileSync(__dirname + '/mock/no-lines.xml').toString(); | ||
describe('Jacoco Parser', function () { | ||
|
||
it('should be to parse jacoco data', function () { | ||
return expect(parser.getParser('jacoco').parse('',jacocoData)) | ||
.to.eventually.satisfy(function (data) { | ||
expect(data).to.deep.equal({ | ||
total: 23, | ||
fileReports: [ | ||
{ | ||
filename: 'com/wmbest/myapplicationtest/MainActivity.java', | ||
coverage: { | ||
8: 0, | ||
11: 2, | ||
12: 1, | ||
13: 7, | ||
18: 0, | ||
19: 0, | ||
20: 0, | ||
25: 0, | ||
26: 0, | ||
34: 0, | ||
37: 0, | ||
38: 0, | ||
41: 0 | ||
}, | ||
total: 23 }] | ||
}); | ||
return true; | ||
}); | ||
}); | ||
|
||
it('should be able to parse jacoco data with path prefix', function () { | ||
return expect(parser.getParser('jacoco').parse(path.normalize('my-project' + path.sep), jacocoData)) | ||
.to.eventually.satisfy(function (data) { | ||
expect(data).to.deep.equal({ | ||
total: 23, | ||
fileReports: [ | ||
{ | ||
filename: 'my-project/com/wmbest/myapplicationtest/MainActivity.java', | ||
coverage: { | ||
8: 0, | ||
11: 2, | ||
12: 1, | ||
13: 7, | ||
18: 0, | ||
19: 0, | ||
20: 0, | ||
25: 0, | ||
26: 0, | ||
34: 0, | ||
37: 0, | ||
38: 0, | ||
41: 0 | ||
}, | ||
total: 23 }] | ||
}); | ||
return true; | ||
}); | ||
}); | ||
|
||
it('should be able to parse jacoco data without lines', function() { | ||
return expect(parser.getParser('jacoco').parse('', noStatsJacocoData)) | ||
.to.eventually.satisfy(function (data) { | ||
expect(JSON.stringify(data)).to.equal(JSON.stringify({ | ||
total: 0, | ||
fileReports: [ | ||
{ | ||
filename: path.normalize('com/wmbest/myapplicationtest/MainActivity.java'), | ||
coverage: {}, | ||
total: 0 | ||
}] | ||
})); | ||
return true; | ||
}); | ||
}); | ||
}); | ||
}(require('fs'), require('../lib/coverageParser'),require('./helper'), require('path'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(function (fs, parser, helper) { | ||
'use strict'; | ||
var expectedCoverage = 40; | ||
var expect = helper.chai.expect; | ||
var jacocoData = fs.readFileSync(__dirname + '/mock/jacoco2.xml').toString(); | ||
|
||
describe('Jacoco Parser', function () { | ||
it('should be able to parse jacoco data with empty files', function () { | ||
return expect(parser.getParser('jacoco').parse('', jacocoData)) | ||
.to.eventually.satisfy(function (data) { | ||
expect(data.total).to.equal(expectedCoverage); | ||
return true; | ||
}); | ||
}); | ||
}); | ||
}(require('fs'), require('../lib/coverageParser'), require('./helper'))); |