项目作者: gstn-caruso

项目描述 :
Extra assertions for SUnit
高级语言: Smalltalk
项目地址: git://github.com/gstn-caruso/SUnit-Assertions-Extra.git
创建时间: 2018-09-13T09:04:30Z
项目社区:https://github.com/gstn-caruso/SUnit-Assertions-Extra

开源协议:MIT License

下载


SUnit extra assertions

These are assertions (or matchers) for SUnit written for cuis Smalltalk inspired by some of the marchers of RSpec.

How to use it

Just import it, these matchers extends TestCase.

Current list of assertions

An action changes something

self assert: [ aCollection add: 1 ] changes: [ aCollection size ]

Also the opposite is included:

self assert: [ aCollection sum ] doesNotChange: [ aCollection size ]

And the parametric versions:

self assert: [ aCollection add: 1; add: 2 ] changes: [ aCollection size ] by: 2

  1. aCollection := OrderedCollection with: 1.
  2. self assert: [ aCollection add: 2 ] changes: [ aCollection size ] from: 1 to: 2

A float number is equal to another float number with a precision value

self assert: (0.3) isNearTo: (0.1 + 0.2)

self assert: originalNumber isNearTo: newValue withPrecision: precision

Also you have the negative assertions:

self assert: originalNumber isNotNearTo: newValue

self assert: originalNumber isNotNearTo: newValue withPrecision: precision

A collection includes an element

self assert: #() includes: 1

Will raise a nice error message