#FEATURE by cg
class: TestCase::Should
class definition
added:
#assertSelector
#beInstanceOf:
#equal:
#not
#raise:
changed: #be:
--- a/TestCase.st Sun Jul 01 12:29:32 2018 +0200
+++ b/TestCase.st Sun Jul 01 12:52:19 2018 +0200
@@ -19,7 +19,7 @@
!
Object subclass:#Should
- instanceVariableNames:'value testCase'
+ instanceVariableNames:'assertSelector shouldNot value testCase'
classVariableNames:''
poolDictionaries:''
privateIn:TestCase
@@ -1113,6 +1113,12 @@
!TestCase::Should methodsFor:'accessing'!
+assertSelector
+ ^ assertSelector ? #'assert:'
+
+ "Created: / 01-07-2018 / 12:42:00 / Claus Gittinger"
+!
+
testCase:something
testCase := something.
!
@@ -1130,9 +1136,59 @@
<resource: #skipInDebuggersWalkBack>
- testCase assert:(value = expectedValue).
+ testCase perform:self assertSelector with:(value = expectedValue).
"Created: / 01-07-2018 / 12:11:46 / Claus Gittinger"
+!
+
+beInstanceOf:expectedClass
+ "for expressions like:
+ value should be:expectedValue
+ inside a testcase"
+
+ <resource: #skipInDebuggersWalkBack>
+
+ testCase perform:self assertSelector with:(value class == expectedClass).
+
+ "Created: / 01-07-2018 / 12:38:38 / Claus Gittinger"
+!
+
+equal:expectedValue
+ "for expressions like:
+ value should equal:expectedValue
+ inside a testcase"
+
+ <resource: #skipInDebuggersWalkBack>
+
+ testCase perform:self assertSelector with:(value = expectedValue).
+
+ "Created: / 01-07-2018 / 12:30:08 / Claus Gittinger"
+!
+
+not
+ assertSelector := #deny:
+
+ "Created: / 01-07-2018 / 12:42:12 / Claus Gittinger"
+!
+
+raise:exceptionClass
+ "for expressions like:
+ value should be:expectedValue
+ inside a testcase"
+
+ <resource: #skipInDebuggersWalkBack>
+
+ self assertSelector == #assert: ifTrue:[
+ testCase should:value raise:exceptionClass
+ ] ifFalse:[
+ self assertSelector == #deny: ifTrue:[
+ testCase shouldnt:value raise:exceptionClass
+ ] ifFalse:[
+ self error.
+ ].
+ ].
+
+ "Created: / 01-07-2018 / 12:39:48 / Claus Gittinger"
! !
!TestCase class methodsFor:'documentation'!