#FEATURE by cg
class: TestCase
hack to support "should be:" inside test case
changed: #performTest
class: TestCase::Should
class definition
added:
#be:
#testCase:
#value:
class: TestCase::Should class
added: #documentation
--- a/TestCase.st Fri Jun 22 03:33:18 2018 +0000
+++ b/TestCase.st Sun Jul 01 12:29:21 2018 +0200
@@ -18,6 +18,13 @@
"
!
+Object subclass:#Should
+ instanceVariableNames:'value testCase'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:TestCase
+!
+
!TestCase class methodsFor:'initialization'!
@@ -730,7 +737,21 @@
!
performTest
- self perform: testSelector sunitAsSymbol
+ "handle unimplemented #should message,
+ so we can write:
+ somthing should be:expectedResult
+ "
+
+ MessageNotUnderstood handle:[:ex |
+ ex selector == #should ifTrue:[
+ ex proceedWith:( Should new testCase:self; value:ex receiver )
+ ].
+ ex reject.
+ ] do:[
+ self perform: testSelector sunitAsSymbol
+ ].
+
+ "Modified: / 01-07-2018 / 12:12:10 / Claus Gittinger"
!
safeTearDown
@@ -1072,6 +1093,48 @@
"can be redefined in a concrete test"
! !
+!TestCase::Should class methodsFor:'documentation'!
+
+documentation
+"
+ documentation to be added.
+
+ [author:]
+ Claus Gittinger
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+
+"
+! !
+
+!TestCase::Should methodsFor:'accessing'!
+
+testCase:something
+ testCase := something.
+!
+
+value:something
+ value := something.
+! !
+
+!TestCase::Should methodsFor:'verifying'!
+
+be:expectedValue
+ "for expressions like:
+ value should be:expectedValue
+ inside a testcase"
+
+ <resource: #skipInDebuggersWalkBack>
+
+ testCase assert:(value = expectedValue).
+
+ "Created: / 01-07-2018 / 12:11:46 / Claus Gittinger"
+! !
+
!TestCase class methodsFor:'documentation'!
version