Skip to content

Commit 677576c

Browse files
author
Wolfram Kriesing
committed
+ bugfixes
+ config option which determines testFunctionName
1 parent 34ec971 commit 677576c

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// mmmmh, if we allow filtering and only running some tests
2+
// we have to adjust doh.register() so numTests etc. have to be adjusted too, right?
3+
// or it will just be "wrong".
4+
doh.config = {
5+
filter:{
6+
groupName:""
7+
},
8+
9+
// testFunctionName: Set the function name where the test is implemented in.
10+
testFunctionName:"test"
11+
};
12+

doh.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ doh = {
8282
var myT = new function(){
8383
this._assertClosure = function(method, args){
8484
// If the Deferred instance is already "done", means callback or errback
85-
// had already been called dont do it again.
85+
// had already been called don't do it again.
8686
// This might be the case when e.g. the test timed out.
8787
if (d.fired > -1){
88+
console.log('FIXXXXXME multiple asserts or timeout ... d.fired = ', d.fired, "GROUP and TEST: '", d.test.group.name, "' " , d.test.name);
8889
return;
8990
}
9091
try{
@@ -94,10 +95,16 @@ doh = {
9495
d.errback(e);
9596
}
9697
};
98+
var that = this;
9799
for (var methodName in doh.assert){
98100
if (methodName.indexOf("assert")===0){
99101
this[methodName] = (function(methodName){return function(){
100-
this._assertClosure(methodName, arguments);
102+
// Make sure the current callstack is worked off before
103+
// returning from any assert() method, we do this by
104+
// setTimeout(). The bug was that assert() didn't make the
105+
// test execute the return statement (if one was in there)
106+
// before the test ended, this fixes it.
107+
setTimeout(doh.util.hitch(that, "_assertClosure", methodName, arguments), 1);
101108
}})(methodName);
102109
}
103110
}
@@ -155,8 +162,8 @@ doh = {
155162
if(t.setUp){
156163
t.setUp(assertWrapperObject);
157164
}
158-
if(!t.test){
159-
t.test = function(){deferred.errback(new Error("Test missing."));}
165+
if(!t[this.config.testFunctionName]){
166+
t[this.config.testFunctionName] = function(){deferred.errback(new Error("Test missing."));}
160167
}
161168
deferred.groupName = g.name;
162169
deferred.test = t;
@@ -207,6 +214,6 @@ doh = {
207214
this._testInFlight = true;
208215

209216
t.startTime = new Date();
210-
t.result = t.test(assertWrapperObject);
217+
t.result = t[this.config.testFunctionName](assertWrapperObject);
211218
}
212219
}

0 commit comments

Comments
 (0)