Opened 10 years ago
Closed 9 years ago
#12487 closed defect (fixed)
DOH tearDown not working as expected
Reported by: | jimvorbau | Owned by: | haysmark |
---|---|---|---|
Priority: | high | Milestone: | 1.8 |
Component: | TestFramework | Version: | 1.5 |
Keywords: | doh tearDown | Cc: | |
Blocked By: | Blocking: |
Description
When running a doh test, the tearDown function of a test will not be called if the test is unsuccessful.
This is very unlike most testing frameworks. setUp should always be called before a test and tearDown after. That way, things like the state of the HTML, etc., can be reset for the next test.
In runner.js, doh._runFixture calls tearDown at the end of a try statement. This line of code shold really go in a finally block.
Here is a suggested change. Change this snippet:
if(fixture["tearDown"]){ fixture.tearDown(this); } }catch(e){ threw = true; err = e; if(!fixture.endTime){ fixture.endTime = new Date(); } }
to this:
}catch(e){ threw = true; err = e; if(!fixture.endTime){ fixture.endTime = new Date(); } } finally { if(fixture["tearDown"]){ fixture.tearDown(this); } }
Change History (8)
comment:1 Changed 10 years ago by
Component: | General → TestFramework |
---|---|
Owner: | changed from anonymous to alex |
comment:2 Changed 10 years ago by
Correct, tearDown() doesn't get called if there is a test failure caused by a normal doh.is() assertion.
comment:3 Changed 10 years ago by
Owner: | changed from alex to haysmark |
---|
comment:4 Changed 9 years ago by
Milestone: | tbd → future |
---|
comment:5 Changed 9 years ago by
Milestone: | future → 1.8 |
---|
comment:7 Changed 9 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
[28985] completely hangs runTest.html.
Tested via dijit/tests/runTest.html on IE8. util/doh/runner.html?testModule=dijit.tests._base.module also hangs.
Make sense.
tearDown() doesn't even get called when the test gets an error because a doh.is(), doh.t() etc. assertion failed?