Opened 9 years ago

Closed 7 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 9 years ago by bill

Component: GeneralTestFramework
Owner: changed from anonymous to alex

Make sense.

tearDown() doesn't even get called when the test gets an error because a doh.is(), doh.t() etc. assertion failed?

comment:2 Changed 9 years ago by jimvorbau

Correct, tearDown() doesn't get called if there is a test failure caused by a normal doh.is() assertion.

comment:3 Changed 9 years ago by bill

Owner: changed from alex to haysmark

comment:4 Changed 8 years ago by haysmark

Milestone: tbdfuture

comment:5 Changed 7 years ago by haysmark

Milestone: future1.8

comment:6 Changed 7 years ago by haysmark

Resolution: fixed
Status: newclosed

In [28985]:

tearDown should be called regardless of the test's outcome. Fixes #12487. !strict

comment:7 Changed 7 years ago by bill

Resolution: fixed
Status: closedreopened

[28985] completely hangs runTest.html.

Tested via dijit/tests/runTest.html on IE8. util/doh/runner.html?testModule=dijit.tests._base.module also hangs.

comment:8 Changed 7 years ago by haysmark

Resolution: fixed
Status: reopenedclosed

In [29040]:

Don't call tearDown in async case (it is called much later). Added new test cases demonstrating problem with tearDown for failing sync tests. Fixes #12487. !strict

Note: See TracTickets for help on using tickets.