Skip to content

Commit

Permalink
Integrate coverage analysis with the test reporter system.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoglan committed Jan 25, 2013
1 parent 0e02790 commit a099383
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions jake.yml
Expand Up @@ -94,6 +94,7 @@ packages:
- reporters/testacular
- reporters/testem
- reporters/test_swarm
- reporters/coverage
- reporters/composite

- context/context
Expand Down
1 change: 1 addition & 0 deletions source/package/config.js
Expand Up @@ -44,6 +44,7 @@ P.packages(function() { with(this) {
'JS.Enumerable',
'JS.SortedSet',
'JS.Range',
'JS.Hash',
'JS.MethodChain',
'JS.Comparable',
'JS.StackTrace')
Expand Down
5 changes: 3 additions & 2 deletions source/test/_head.js
Expand Up @@ -7,12 +7,13 @@
Enumerable = js.Enumerable || require('./enumerable').Enumerable,
SortedSet = js.SortedSet || require('./set').SortedSet,
Range = js.Range || require('./range').Range,
Hash = js.Hash || require('./hash').Hash,
MethodChain = js.MethodChain || require('./method_chain').MethodChain,
Comparable = js.Comparable || require('./comparable').Comparable,
StackTrace = js.StackTrace || require('./stack_trace').StackTrace;

if (E) exports.JS = exports;
factory(js, Console, DOM, Enumerable, SortedSet, Range, MethodChain, Comparable, StackTrace, E ? exports : js);
factory(js, Console, DOM, Enumerable, SortedSet, Range, Hash, MethodChain, Comparable, StackTrace, E ? exports : js);

})(function(JS, Console, DOM, Enumerable, SortedSet, Range, MethodChain, Comparable, StackTrace, exports) {
})(function(JS, Console, DOM, Enumerable, SortedSet, Range, Hash, MethodChain, Comparable, StackTrace, exports) {

6 changes: 3 additions & 3 deletions source/test/coverage.js
Expand Up @@ -2,7 +2,7 @@ Test.extend({
Coverage: new JS.Class({
initialize: function(module) {
this._module = module;
this._methods = new JS.Hash([]);
this._methods = new Hash([]);

var storeMethods = function(module) {
var methods = module.instanceMethods(false),
Expand All @@ -15,14 +15,14 @@ Test.extend({

attach: function() {
var module = this._module;
JS.StackTrace.addObserver(this);
StackTrace.addObserver(this);
JS.Method.trace([module, module.__eigen__()]);
},

detach: function() {
var module = this._module;
JS.Method.untrace([module, module.__eigen__()]);
JS.StackTrace.removeObserver(this);
StackTrace.removeObserver(this);
},

update: function(event, frame) {
Expand Down
29 changes: 29 additions & 0 deletions source/test/reporters/coverage.js
@@ -0,0 +1,29 @@
Test.Reporters.extend({
Coverage: new JS.Class({
include: Console,

startSuite: function(event) {},

startContext: function(event) {},

startTest: function(event) {},

addFault: function(event) {},

endTest: function(event) {},

endContext: function(event) {},

update: function(event) {},

endSuite: function(event) {
var reports = Test.Unit.TestCase.reports;
for (var i = 0, n = reports.length; i < n; i++) {
this.reset();
this.puts('');
reports[i].report();
}
}
})
});

1 change: 0 additions & 1 deletion source/test/runner.js
Expand Up @@ -39,7 +39,6 @@ Test.extend({
testResult.removeListener(TR.CHANGED, resultListener);
testResult.removeListener(TR.FAULT, faultListener);

// TODO output reports
var result = testResult.metadata();
this._reporter.endSuite(this.klass.timestamp(result));
};
Expand Down
1 change: 1 addition & 0 deletions source/test/ui/terminal.js
Expand Up @@ -30,6 +30,7 @@ Test.UI.extend({
R = Test.Reporters;

var Printer = R.get(options.format) || R.Dot;
reporters.push(new R.Coverage(options));
reporters.push(new Printer(options));
reporters.push(new R.ExitStatus(options));

Expand Down

0 comments on commit a099383

Please sign in to comment.