prashant624 / js-test-driver

Automatically exported from code.google.com/p/js-test-driver
0 stars 0 forks source link

AsyncTestCase, client dies when assert return false before callback executed #318

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.write AsyncTestCase, add callbacks
2.add "assertEquals(1, 2, 'false'); callback()" in setTimeout
3.run testcase

What is the expected output? What do you see instead?
Test fails, but the client should not be dead
but now the client is dead, no log is printed

What version of the product are you using? On what operating system?
jsTestDriver 1.3.3
Server : windows XP
client : windows XP

Please provide any additional information below.
wrong way : 
var AsyncTest = AsyncTestCase('test');
AsyncTest.prototype.testAssertFalseBeforeCallback = function(queue) {
    queue.call('test', function(callbacks) {
        var callback = callbacks.add(function() {});
        setTimeout(function() {
            assertTrue('test',false);  //---------wrong way---------
            callback();
        }, 10);
        Clock.tick(100);
    });
}

correct way :
var AsyncTest = AsyncTestCase('test');
AsyncTest.prototype.testAssertFalseBeforeCallback = function(queue) {
    queue.call('test', function(callbacks) {
        var callback = callbacks.add(function() {
            assertTrue('test',false);  //-----------correct way----------
        });
        setTimeout(function() {
            callback();
        }, 10);
        Clock.tick(100);
    });
}

Original issue reported on code.google.com by wangj...@gmail.com on 27 Dec 2011 at 7:05

GoogleCodeExporter commented 8 years ago
I find the reason now, setTimeout provided by jsUnitMockTimeout.js executes 
every function with try-catch, assertTrue throws AssertError if the assert is 
not success, which will make the execution stop, and callback won't be executed 
now....

Original comment by wangj...@gmail.com on 27 Dec 2011 at 7:52

GoogleCodeExporter commented 8 years ago
On the basis that the test uses jsUnitMockTimeout.js, I'm putting this one down 
as test error.

Original comment by corbinrs...@gmail.com on 27 Dec 2011 at 5:09