Permalink
Browse files

Integrate coverage analysis with the test reporter system.

  • Loading branch information...
1 parent 0e02790 commit a099383614ad929fe64377ad2955c39272f762aa @jcoglan committed Jan 25, 2013
View
@@ -94,6 +94,7 @@ packages:
- reporters/testacular
- reporters/testem
- reporters/test_swarm
+ - reporters/coverage
- reporters/composite
- context/context
@@ -44,6 +44,7 @@ P.packages(function() { with(this) {
'JS.Enumerable',
'JS.SortedSet',
'JS.Range',
+ 'JS.Hash',
'JS.MethodChain',
'JS.Comparable',
'JS.StackTrace')
@@ -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) {
@@ -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),
@@ -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) {
@@ -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();
+ }
+ }
+ })
+});
+
@@ -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));
};
@@ -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));

0 comments on commit a099383

Please sign in to comment.