1
0
Selaa lähdekoodia

tearDown call moved to TestResult >> runCase:

Herby Vojčík 12 vuotta sitten
vanhempi
commit
868fdfe7a2
3 muutettua tiedostoa jossa 50 lisäystä ja 9 poistoa
  1. 17 1
      js/SUnit.deploy.js
  2. 25 4
      js/SUnit.js
  3. 8 4
      st/SUnit.st

+ 17 - 1
js/SUnit.deploy.js

@@ -188,6 +188,18 @@ fn: function (aString) {
 }),
 smalltalk.TestCase);
 
+smalltalk.addMethod(
+"_startCase",
+smalltalk.method({
+selector: "startCase",
+fn: function (){
+var self=this;
+smalltalk.send(self,"_setUp",[]);
+smalltalk.send(self,"_performTest",[]);
+return self}
+}),
+smalltalk.TestCase);
+
 smalltalk.addMethod(
 "_tearDown",
 smalltalk.method({
@@ -401,8 +413,12 @@ fn: function (aTestCase){
 var self=this;
 smalltalk.send((function(){
 return smalltalk.send((function(){
+return smalltalk.send((function(){
 smalltalk.send(self,"_increaseRuns",[]);
-return smalltalk.send(aTestCase,"_runCase",[]);
+return smalltalk.send(aTestCase,"_startCase",[]);
+}),"_ensure_",[(function(){
+return smalltalk.send(aTestCase,"_tearDown",[]);
+})]);
 }),"_on_do_",[(smalltalk.TestFailure || TestFailure),(function(ex){
 return smalltalk.send(self,"_addFailure_",[aTestCase]);
 })]);

+ 25 - 4
js/SUnit.js

@@ -137,7 +137,7 @@ return smalltalk.send(self,"_tearDown",[]);
 })]);
 return self},
 args: [],
-source: "runCase\x0a\x09[\x09self setUp.\x0a\x09\x09self performTest ] ensure: [\x0a\x09\x09self tearDown.\x0a\x09\x09\x22self cleanUpInstanceVariables\x22 ]\x0a",
+source: "runCase\x0a\x09[\x09self setUp.\x0a\x09\x09self performTest ] ensure: [\x0a\x09\x09self tearDown ]\x0a",
 messageSends: ["ensure:", "tearDown", "setUp", "performTest"],
 referencedClasses: []
 }),
@@ -263,6 +263,23 @@ referencedClasses: ["TestFailure"]
 }),
 smalltalk.TestCase);
 
+smalltalk.addMethod(
+"_startCase",
+smalltalk.method({
+selector: "startCase",
+category: 'running',
+fn: function (){
+var self=this;
+smalltalk.send(self,"_setUp",[]);
+smalltalk.send(self,"_performTest",[]);
+return self},
+args: [],
+source: "startCase\x0a\x09self setUp.\x0a\x09self performTest\x0a",
+messageSends: ["setUp", "performTest"],
+referencedClasses: []
+}),
+smalltalk.TestCase);
+
 smalltalk.addMethod(
 "_tearDown",
 smalltalk.method({
@@ -552,8 +569,12 @@ fn: function (aTestCase){
 var self=this;
 smalltalk.send((function(){
 return smalltalk.send((function(){
+return smalltalk.send((function(){
 smalltalk.send(self,"_increaseRuns",[]);
-return smalltalk.send(aTestCase,"_runCase",[]);
+return smalltalk.send(aTestCase,"_startCase",[]);
+}),"_ensure_",[(function(){
+return smalltalk.send(aTestCase,"_tearDown",[]);
+})]);
 }),"_on_do_",[(smalltalk.TestFailure || TestFailure),(function(ex){
 return smalltalk.send(self,"_addFailure_",[aTestCase]);
 })]);
@@ -562,8 +583,8 @@ return smalltalk.send(self,"_addError_",[aTestCase]);
 })]);
 return self},
 args: ["aTestCase"],
-source: "runCase: aTestCase\x0a\x09[[\x09self increaseRuns.\x0a    \x09aTestCase runCase]\x0a\x09on: TestFailure do: [:ex | self addFailure: aTestCase]]\x0a\x09on: Error do: [:ex | self addError: aTestCase]\x0a",
-messageSends: ["on:do:", "addError:", "addFailure:", "increaseRuns", "runCase"],
+source: "runCase: aTestCase\x0a\x09[[[\x09self increaseRuns.\x0a    \x09aTestCase startCase ] ensure: [ aTestCase tearDown ]]\x0a\x09on: TestFailure do: [:ex | self addFailure: aTestCase]]\x0a\x09on: Error do: [:ex | self addError: aTestCase]\x0a",
+messageSends: ["on:do:", "addError:", "addFailure:", "ensure:", "tearDown", "increaseRuns", "startCase"],
 referencedClasses: ["Error", "TestFailure"]
 }),
 smalltalk.TestResult);

+ 8 - 4
st/SUnit.st

@@ -44,13 +44,17 @@ performTest
 runCase
 	[	self setUp.
 		self performTest ] ensure: [
-		self tearDown.
-		"self cleanUpInstanceVariables" ]
+		self tearDown ]
 !
 
 setUp
 !
 
+startCase
+	self setUp.
+	self performTest
+!
+
 tearDown
 ! !
 
@@ -202,8 +206,8 @@ or does nothing if no more runs"
 !
 
 runCase: aTestCase
-	[[	self increaseRuns.
-    	aTestCase runCase]
+	[[[	self increaseRuns.
+    	aTestCase startCase ] ensure: [ aTestCase tearDown ]]
 	on: TestFailure do: [:ex | self addFailure: aTestCase]]
 	on: Error do: [:ex | self addError: aTestCase]
 ! !