Permalink
Browse files

Also bind the test object on setUp and tearDown calls

  • Loading branch information...
Zach Carter
Zach Carter committed Mar 31, 2009
1 parent 99152ce commit 40db1e8bb15dfc3287f493835181bd5e210de9e9
Showing with 32 additions and 2 deletions.
  1. +2 −2 jsunity/jsunity.js
  2. +30 −0 jsunity/test/coreTestSuite.js
View
@@ -361,9 +361,9 @@ jsUnity = (function () {
var test = suite.tests[j];
try {
- suite.setUp && suite.setUp();
+ suite.setUp && suite.setUp.call(suite.scope);
test.fn.call(suite.scope);
- suite.tearDown && suite.tearDown();
+ suite.tearDown && suite.tearDown.call(suite.scope);
results.passed++;
@@ -452,5 +452,35 @@ function CoreTestSuite() {
a.assertIdentical(1, results.passed);
}
+
+ function testRunObjectBindsObjectAsSetUpScope() {
+ var results = jsUnity.run({
+ setUp: function () {
+ this.marker = true;
+ },
+ testMarker: function () {
+ a.assertTrue(this.marker);
+ }
+ });
+
+ a.assertIdentical(1, results.passed);
+ }
+
+ function testRunObjectBindsObjectAsTearDownScope() {
+ var results = jsUnity.run({
+ tearDown: function () {
+ this.marker = true;
+ },
+ testNoop: function () {
+ a.assertTrue(true);
+ },
+ testMarker: function () {
+ a.assertTrue(this.marker);
+ }
+ });
+
+ a.assertIdentical(2, results.passed);
+ }
+
}
//%>

0 comments on commit 40db1e8

Please sign in to comment.