On Thursday 15 April 2010 16:38:13 Holger Hans Peter Freyther wrote:
> On Thursday 15 April 2010 16:37:26 you wrote:
> > On Thursday 15 April 2010 15:41:27 you wrote:
> > > This is wrong, otherwise looks great.
> >
> > oops, this must have sneaked in with the last rebase. Should I rebase and
> > send updated patches?
>
> Oh that was too fast. I will send updated patches I need to write ChangeLog
> entries too. :)
Hi all,
this is an updated changeset, the patch four has the garbage removed and I
added ChangeLog entries. Is that ready to merge? Is there anything missing?
regards
holger
From 97e3b53e8ed8537144f6e50c2581e140452c6abc Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <[email protected]>
Date: Thu, 15 Apr 2010 13:01:37 +0200
Subject: [PATCH 1/4] SUnit: Initialize errors, failures and passed in the initialize method
This is needed to help merging the Pharo changes on SUnit as
the passed and errors selector were redefined to collect the
information from two other selectors.
---
packages/sunit/ChangeLog | 5 +++++
packages/sunit/SUnit.st | 21 ++++++++++-----------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/packages/sunit/ChangeLog b/packages/sunit/ChangeLog
index a4daee6..2d319a9 100644
--- a/packages/sunit/ChangeLog
+++ b/packages/sunit/ChangeLog
@@ -1,3 +1,8 @@
+2010-04-15 Holger Hans Peter Freyther <[email protected]>
+
+ * packages/sunit/SUnit.st: Allocate passed, errors and failures
+ of TestResult inside the #initialize.
+
2009-10-31 Paolo Bonzini <[email protected]>
* packages/sunit/SUnit.st: Set null logging when running #debug.
diff --git a/packages/sunit/SUnit.st b/packages/sunit/SUnit.st
index e21e9ca..004627e 100644
--- a/packages/sunit/SUnit.st
+++ b/packages/sunit/SUnit.st
@@ -300,7 +300,6 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
errors [
<category: 'Accessing'>
- errors isNil ifTrue: [errors := Set new].
^errors
]
@@ -311,13 +310,11 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
failures [
<category: 'Accessing'>
- failures isNil ifTrue: [failures := Set new].
^failures
]
passed [
<category: 'Accessing'>
- passed isNil ifTrue: [passed := OrderedCollection new].
^passed
]
@@ -334,9 +331,9 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
tests [
<category: 'Accessing'>
^(OrderedCollection new: self runCount)
- addAll: self passed;
- addAll: self errors;
- addAll: self failures;
+ addAll: passed;
+ addAll: errors;
+ addAll: failures;
yourself
]
@@ -372,7 +369,9 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
initialize [
<category: 'Init / Release'>
-
+ errors := Set new.
+ failures := Set new.
+ passed := OrderedCollection new.
]
runCase: aTestCase [
@@ -385,16 +384,16 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
true] sunitOn: self class failure
do:
[:signal |
- self failures add: aTestCase.
+ failures add: aTestCase.
signal sunitExitWith: false]]
sunitOn: self class error
do:
[:signal |
- (self errors includes: aTestCase) ifFalse: [aTestCase logError: signal].
- self errors add: aTestCase.
+ (errors includes: aTestCase) ifFalse: [aTestCase logError: signal].
+ errors add: aTestCase.
signal sunitExitWith: false].
aTestCase logPolicy flush.
- testCasePassed ifTrue: [self passed add: aTestCase]
+ testCasePassed ifTrue: [passed add: aTestCase]
]
printOn: aStream [
--
1.7.0.4
From 1b76f46ca34c7812506abe08df22c26d785cbbc1 Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <[email protected]>
Date: Thu, 15 Apr 2010 13:27:24 +0200
Subject: [PATCH 2/4] SUnit: Add new selectors from Pharo for handling (un)expected failures/success
Add new selectors to handle expected failures and unexpected
success on test cases. The code is not yet used.
This is coming from the Pharo1.0-10508-rc2dev10.01.2 image.
---
packages/sunit/ChangeLog | 9 ++++++
packages/sunit/SUnit.st | 63 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/packages/sunit/ChangeLog b/packages/sunit/ChangeLog
index 2d319a9..c28ddbd 100644
--- a/packages/sunit/ChangeLog
+++ b/packages/sunit/ChangeLog
@@ -1,5 +1,14 @@
2010-04-15 Holger Hans Peter Freyther <[email protected]>
+ * packages/sunit/SUnit.st: Add selectors #expectedFailures,
+ #shouldPass to TestCase, add selectors #expectedDefectCount,
+ #expectedDefects, #expectedPassCount, #expectedPasses,
+ #unexpectedErrorCount, #unexpectedErrors, #unexpectedFailureCount,
+ #unexpectedFailures, #unexpectedPassCount, #unexpectedPasses to
+ TestClass.
+
+2010-04-15 Holger Hans Peter Freyther <[email protected]>
+
* packages/sunit/SUnit.st: Allocate passed, errors and failures
of TestResult inside the #initialize.
diff --git a/packages/sunit/SUnit.st b/packages/sunit/SUnit.st
index 004627e..f187c8d 100644
--- a/packages/sunit/SUnit.st
+++ b/packages/sunit/SUnit.st
@@ -303,6 +303,57 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
^errors
]
+ expectedDefectCount [
+ <category: 'Accessing'>
+ ^self expectedDefects size
+ ]
+
+ expectedDefects [
+ <category: 'Accessing'>
+ ^errors , failures asOrderedCollection
+ select: [:each | each shouldPass not]
+ ]
+
+ expectedPassCount [
+ <category: 'Accessing'>
+ ^self expectedPasses size
+ ]
+
+ expectedPasses [
+ <category: 'Accessing'>
+ ^passed select: [:each | each shouldPass]
+ ]
+
+ unexpectedErrorCount [
+ <category: 'Accessing'>
+ ^self unexpectedErrors size
+ ]
+
+ unexpectedErrors [
+ <category: 'Accessing'>
+ ^errors select: [:each | each shouldPass]
+ ]
+
+ unexpectedFailureCount [
+ <category: 'Accessing'>
+ ^self unexpectedFailures size
+ ]
+
+ unexpectedFailures [
+ <category: 'Accessing'>
+ ^failures select: [:each | each shouldPass]
+ ]
+
+ unexpectedPassCount [
+ <category: 'Accessing'>
+ ^self unexpectedPasses size
+ ]
+
+ unexpectedPasses [
+ <category: 'Accessing'>
+ ^passed select: [:each | each shouldPass not]
+ ]
+
failureCount [
<category: 'Accessing'>
^self failures size
@@ -986,6 +1037,18 @@ When you are writing a test case method, send #assert: aBoolean when you want to
]
+ expectedFailures [
+ <category: 'Testing'>
+ ^Array new
+ ]
+
+ shouldPass [
+ "Unless the selector is in the list we get from #expectedFailures, we expect it to pass"
+
+ <category: 'Testing'>
+ ^(self expectedFailures includes: testSelector) not
+ ]
+
executeShould: aBlock inScopeOf: anExceptionalEvent [
<category: 'Private'>
^
--
1.7.0.4
From 60d8a9f9d949198d16724d0b1d2530eaf9e5f173 Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <[email protected]>
Date: Thu, 15 Apr 2010 14:02:30 +0200
Subject: [PATCH 3/4] SUnit: Use the new selectors for (un)expected failure/success
Use the new selectors to handle unexpected success and
expected success on test cases. The change is coming from
the Pharo image.
Right now the plural handling for errors/failures is lost.
---
packages/sunit/ChangeLog | 6 ++++++
packages/sunit/SUnit.st | 23 +++++++++++++----------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/packages/sunit/ChangeLog b/packages/sunit/ChangeLog
index c28ddbd..6cad42d 100644
--- a/packages/sunit/ChangeLog
+++ b/packages/sunit/ChangeLog
@@ -1,5 +1,11 @@
2010-04-15 Holger Hans Peter Freyther <[email protected]>
+ * packages/sunit/SUnit.st: Change #errors, #passed,
+ #runCount and #printOn to handle expected failures and
+ unexpected success.
+
+2010-04-15 Holger Hans Peter Freyther <[email protected]>
+
* packages/sunit/SUnit.st: Add selectors #expectedFailures,
#shouldPass to TestCase, add selectors #expectedDefectCount,
#expectedDefects, #expectedPassCount, #expectedPasses,
diff --git a/packages/sunit/SUnit.st b/packages/sunit/SUnit.st
index f187c8d..49bd9d6 100644
--- a/packages/sunit/SUnit.st
+++ b/packages/sunit/SUnit.st
@@ -300,7 +300,7 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
errors [
<category: 'Accessing'>
- ^errors
+ ^self unexpectedErrors
]
expectedDefectCount [
@@ -366,7 +366,7 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
passed [
<category: 'Accessing'>
- ^passed
+ ^self expectedPasses, self expectedDefects
]
passedCount [
@@ -376,7 +376,7 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
runCount [
<category: 'Accessing'>
- ^self passedCount + self failureCount + self errorCount
+ ^passed size + failures size + errors size
]
tests [
@@ -452,13 +452,16 @@ This is a Collecting Parameter for the running of a bunch of tests. TestResult i
aStream
nextPutAll: self runCount printString;
nextPutAll: ' run, ';
- nextPutAll: self passedCount printString;
- nextPutAll: ' passed, ';
- nextPutAll: self failureCount printString;
- nextPutAll: ' failed, ';
- nextPutAll: self errorCount printString;
- nextPutAll: ' error'.
- self errorCount ~= 1 ifTrue: [aStream nextPut: $s]
+ nextPutAll: self expectedPassCount printString;
+ nextPutAll: ' passes, ';
+ nextPutAll: self expectedDefectCount printString;
+ nextPutAll: ' expected failures, ';
+ nextPutAll: self unexpectedFailureCount printString;
+ nextPutAll: ' failures, ';
+ nextPutAll: self unexpectedErrorCount printString;
+ nextPutAll: ' errors, ';
+ nextPutAll: self unexpectedPassCount printString;
+ nextPutAll: ' unexpected passes'
]
]
--
1.7.0.4
From b0ce503ad45eddbf5f71155a20b6224a783f215a Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <[email protected]>
Date: Thu, 15 Apr 2010 14:48:04 +0200
Subject: [PATCH 4/4] SUnit: Add a test case for expectedDefects and unexpectedPasses
---
packages/sunit/ChangeLog | 5 +++++
packages/sunit/SUnitTests.st | 33 +++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/packages/sunit/ChangeLog b/packages/sunit/ChangeLog
index 6cad42d..bdcfb44 100644
--- a/packages/sunit/ChangeLog
+++ b/packages/sunit/ChangeLog
@@ -1,5 +1,10 @@
2010-04-15 Holger Hans Peter Freyther <[email protected]>
+ * packages/sunit/SUnitTest.st: Add testcase for expected failures
+ and unexpected success.
+
+2010-04-15 Holger Hans Peter Freyther <[email protected]>
+
* packages/sunit/SUnit.st: Change #errors, #passed,
#runCount and #printOn to handle expected failures and
unexpected success.
diff --git a/packages/sunit/SUnitTests.st b/packages/sunit/SUnitTests.st
index 289001d..d1160a1 100644
--- a/packages/sunit/SUnitTests.st
+++ b/packages/sunit/SUnitTests.st
@@ -249,6 +249,24 @@ if the tests are hard to write, something is probably wrong with the design".'>
errors: 1
]
+ testExpectedFailures [
+ <category: 'Testing'>
+ | result suite expected failed error |
+ suite := TestSuite new.
+ suite addTest: (expected := SUnitClientTest selector: #generateExpectedFailure).
+ suite addTest: (failed := SUnitClientTest selector: #generateUnexpectedSuccess).
+ result := suite run.
+ self assert: (result expectedDefects includes: expected).
+ self assert: (result unexpectedPasses includes: failed).
+
+ self
+ assertForTestResult: result
+ runCount: 2
+ passed: 1
+ failed: 1
+ errors: 0
+ ]
+
assertForTestResult: aResult runCount: aRunCount passed: aPassedCount failed: aFailureCount errors: anErrorCount [
<category: 'Private'>
self
@@ -430,6 +448,21 @@ will run.'>
<category: 'Running'>
hasSetup := true
]
+
+ expectedFailures [
+ <category: 'Private'>
+ ^#(#generateExpectedFailure #generateUnexpectedSuccess)
+ ]
+
+ generateExpectedFailure [
+ <category: 'Private'>
+ self assert: false
+ ]
+
+ generateUnexpectedSuccess [
+ <category: 'Private'>
+ self assert: true
+ ]
]
--
1.7.0.4
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk