Skip to content

Commit

Permalink
Add TestAsserter>>#should:notTakeMoreThanMilliseconds: to GS64
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Jan 3, 2024
1 parent 7284f34 commit 095245e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 25 deletions.
21 changes: 15 additions & 6 deletions source/Buoy-SUnit-GS64-Extensions/TestAsserter.extension.st
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Extension { #name : #TestAsserter }
Extension { #name : 'TestAsserter' }

{ #category : #'*Buoy-SUnit-GS64-Extensions' }
{ #category : '*Buoy-SUnit-GS64-Extensions' }
TestAsserter >> assert: actual identicalTo: expected [

self assert: expected == actual
]

{ #category : #'*Buoy-SUnit-GS64-Extensions' }
{ #category : '*Buoy-SUnit-GS64-Extensions' }
TestAsserter >> assertCollection: actual hasSameElements: expected [
"Assert that a collection contains the same elements as the given collection. Order is not checked, only the presence/absence of elements. Occurences of elements mater."

Expand All @@ -33,20 +33,29 @@ TestAsserter >> assertCollection: actual hasSameElements: expected [
lf ])
]

{ #category : #'*Buoy-SUnit-GS64-Extensions' }
{ #category : '*Buoy-SUnit-GS64-Extensions' }
TestAsserter >> deny: actual identicalTo: expected [

self deny: expected == actual
]

{ #category : #'*Buoy-SUnit-GS64-Extensions' }
{ #category : '*Buoy-SUnit-GS64-Extensions' }
TestAsserter >> fail [
"I make my receiver fail with TestFailure"

^ self assert: false
]

{ #category : #'*Buoy-SUnit-GS64-Extensions' }
{ #category : '*Buoy-SUnit-GS64-Extensions' }
TestAsserter >> should: aBlock notTakeMoreThanMilliseconds: anInteger [

| runtime |

runtime := Time millisecondsToRun: aBlock.
self assert: runtime <= anInteger
]

{ #category : '*Buoy-SUnit-GS64-Extensions' }
TestAsserter >> should: aBlock raise: anException withExceptionDo: anotherBlock [

| exceptionWasRaised |
Expand Down
8 changes: 4 additions & 4 deletions source/Buoy-SUnit-GS64-Extensions/TestCase.extension.st
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Extension { #name : #TestCase }
Extension { #name : 'TestCase' }

{ #category : #'*Buoy-SUnit-GS64-Extensions' }
{ #category : '*Buoy-SUnit-GS64-Extensions' }
TestCase >> runOnlyInGemStone64: aBlock [

aBlock value
]

{ #category : #'*Buoy-SUnit-GS64-Extensions' }
{ #category : '*Buoy-SUnit-GS64-Extensions' }
TestCase >> runOnlyInPharo: aBlock [

]

{ #category : #'*Buoy-SUnit-GS64-Extensions' }
{ #category : '*Buoy-SUnit-GS64-Extensions' }
TestCase >> runOnlyInVAST: aBlock [

]
2 changes: 1 addition & 1 deletion source/Buoy-SUnit-GS64-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'Buoy-SUnit-GS64-Extensions' }
Package { #name : 'Buoy-SUnit-GS64-Extensions' }
39 changes: 26 additions & 13 deletions source/Buoy-SUnit-Tests/TestAsserterBuoyExtensionsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
Unit test for Test Asserter
"
Class {
#name : #TestAsserterBuoyExtensionsTest,
#superclass : #TestCase,
#category : #'Buoy-SUnit-Tests'
#name : 'TestAsserterBuoyExtensionsTest',
#superclass : 'TestCase',
#category : 'Buoy-SUnit-Tests',
#package : 'Buoy-SUnit-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testAssertIncludes [

| asserter |
Expand All @@ -18,7 +19,7 @@ TestAsserterBuoyExtensionsTest >> testAssertIncludes [
self should: [ asserter assert: #(1 2) includes: 3 ] raise: TestFailure
]

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testAssertionFailedInRaiseWithExceptionDo [

| asserter |
Expand All @@ -27,7 +28,7 @@ TestAsserterBuoyExtensionsTest >> testAssertionFailedInRaiseWithExceptionDo [
self should: [ asserter should: [ Error signal ] raise: Error withExceptionDo: [ :aSignal | asserter fail ] ] raise: TestFailure
]

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testDenyIncludes [

| asserter |
Expand All @@ -38,7 +39,7 @@ TestAsserterBuoyExtensionsTest >> testDenyIncludes [
self shouldnt: [ asserter deny: #(1 2) includes: 3 ] raise: TestFailure
]

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testDifferentExceptionInShouldRaiseWithExceptionDo [

| asserter |
Expand All @@ -47,7 +48,7 @@ TestAsserterBuoyExtensionsTest >> testDifferentExceptionInShouldRaiseWithExcepti
self should: [ asserter should: [ Exception signal ] raise: Error withExceptionDo: [ :aSignal | asserter fail ] ] raise: Exception
]

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testErrorInRaiseWithExceptionDo [

| asserter |
Expand All @@ -61,7 +62,7 @@ TestAsserterBuoyExtensionsTest >> testErrorInRaiseWithExceptionDo [
raise: Error
]

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testFail [

| asserter |
Expand All @@ -71,7 +72,7 @@ TestAsserterBuoyExtensionsTest >> testFail [
raise: TestFailure
]

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testNoExceptionInShouldRaiseWithExceptionDo [

| asserter |
Expand All @@ -85,7 +86,19 @@ TestAsserterBuoyExtensionsTest >> testNoExceptionInShouldRaiseWithExceptionDo [
raise: TestFailure
]

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testShouldNotTakeMoreThanMilliseconds [

| asserter |

asserter := TestAsserter new.
self shouldnt: [ asserter should: [ ] notTakeMoreThanMilliseconds: 500 ] raise: TestFailure.
self
should: [ asserter should: [ ( Delay forMilliseconds: 51 ) wait ] notTakeMoreThanMilliseconds: 50 ]
raise: TestFailure
]

{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testShouldRaiseWithExceptionDoTest [

| asserter |
Expand All @@ -99,7 +112,7 @@ TestAsserterBuoyExtensionsTest >> testShouldRaiseWithExceptionDoTest [
withExceptionDo: [:error | asserter assert: error tag = 1]
]

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testShouldRaiseWithMessageText [

| asserter |
Expand All @@ -120,7 +133,7 @@ TestAsserterBuoyExtensionsTest >> testShouldRaiseWithMessageText [
raise: TestFailure
]

{ #category : #tests }
{ #category : 'tests' }
TestAsserterBuoyExtensionsTest >> testWithTheOnlyOneInDo [

| asserter |
Expand Down
2 changes: 1 addition & 1 deletion source/Buoy-SUnit-Tests/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'Buoy-SUnit-Tests' }
Package { #name : 'Buoy-SUnit-Tests' }

0 comments on commit 095245e

Please sign in to comment.