The Inbox: SUnit-ct.124.mcz

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

The Inbox: SUnit-ct.124.mcz

Christoph Thiede uploaded a new version of SUnit to project The Inbox:

==================== Summary ====================

Name: SUnit-ct.124
Author: ct
Time: 20 March 2020, 8:01:47.398237 pm
UUID: d936b6a0-e7c7-2742-a817-35fa6511a15a
Ancestors: SUnit-mt.121

Proposal for discussion: Adds assertion message #should:raise:then: to allow for interactively working with expected exceptions. If you like, we could also talk about #should:raise:that: (however, I still like BlockClosure >> #handles:*).


TestCase new in: [:test |
                should: [
                                should: [self error: #foo]
                                raise: Error
                                then: #pass]
                raise: UnhandledError.
                        should: [self error: #foo]
                        raise: Error
                        then: [:ex |
                                test assert: #foo equals: ex messageText].

* See exception patterns:

=============== Diff against SUnit-mt.121 ===============

Item was added:
+ ----- Method: TestCase>>should:raise:then: (in category 'accessing') -----
+ should: aBlock raise: anExceptionalEvent then: aHandlerBlock
+ | raised result |
+ raised := false.
+ result := aBlock
+ on: anExceptionalEvent
+ do: [:ex |
+ raised := true.
+ aHandlerBlock cull: ex].
+ self assert: raised.
+ ^ result!