Excel-TDD v1.3.0
- Add
ToMatch
,ToBeCloseTo
,ToBeNothing
,ToBeEmpty
,ToBeNull
, andToBeMissing
- Add
RunMatcher
- Change
ToContains
to check if an Array/Collection contains an item, deprecated checking if string contains substring forToMatch
- Improve Mac support
ToMatch
Check if substring matches (is contained in) actual string (RegEx to be added in the future)
.Expect("ABCD").ToContain "BC" ' -> Deprecated
.Expect("ABCD").ToMatch "BC" ' -> Pass
.Expect("ABCD").ToMatch "bc" ' -> Fail
ToBeCloseTo
Check if expected is close to actual for the given number of decimal places
.Expect(1.49).ToBeCloseTo 1.5, 1 ' -> Pass
.Expect(1.49).ToBeCloseTo 1.5, 2 ' -> Fail
RunMatcher
Run a custom matcher
Public Function ToBeWithin(Actual As Variant, Args As Variant) As Variant
If UBound(Args) - LBound(Args) < 1 Then
' Return string for specific failure message
ToBeWithin = "Need to pass in upper-bound to ToBeWithin"
Else
If Actual >= Args(0) And Actual <= Args(1) Then
' Return true for pass
ToBeWithin = True
Else
' Return false for fail or custom failure message
ToBeWithin = False
End If
End If
End Function
.Expect(100).RunMatcher "ToBeWithin", "to be within", 90, 100 ' -> Pass
.Expect(100).RunMatcher "ToBeWithin", "to be within", 90, 95
' -> Fail: Expected 100 to be within 90 and 95
.Expect(100).RunMatcher "ToBeWithin", "to be within", 90
' -> Fail: Need to pass in upper-bound to ToBeWithin