help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] [PATCH] sunit: Fix TestCase new printString signals an


From: Holger Hans Peter Freyther
Subject: [Help-smalltalk] [PATCH] sunit: Fix TestCase new printString signals an exception
Date: Sat, 4 Aug 2012 12:51:09 +0200

From: Holger Hans Peter Freyther <address@hidden>

testSelector is nil before the execution of the testcase.

2012-08-03  Holger Hans Peter Freyther  <address@hidden>

        * packages/sunit/SUnit.st: Only print the testSelector if it
        is not nil.
        * packages/sunit/SUnitTest.st: Add #testPrintString.
---
 packages/sunit/ChangeLog     |    6 ++++++
 packages/sunit/SUnit.st      |    8 +++++---
 packages/sunit/SUnitTests.st |    8 ++++++++
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/packages/sunit/ChangeLog b/packages/sunit/ChangeLog
index 8449214..46d9dd2 100644
--- a/packages/sunit/ChangeLog
+++ b/packages/sunit/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-03  Holger Hans Peter Freyther  <address@hidden>
+
+       * packages/sunit/SUnit.st: Only print the testSelector if it
+       is not nil.
+       * packages/sunit/SUnitTest.st: Add #testPrintString.
+
 2010-12-04  Paolo Bonzini  <address@hidden>
 
        * package.xml: Remove now superfluous <file> tags.
diff --git a/packages/sunit/SUnit.st b/packages/sunit/SUnit.st
index bb814f9..95975c7 100644
--- a/packages/sunit/SUnit.st
+++ b/packages/sunit/SUnit.st
@@ -1102,9 +1102,11 @@ When you are writing a test case method, send #assert: 
aBoolean when you want to
     printOn: aStream [
        <category: 'Printing'>
        aStream
-           nextPutAll: self class printString;
-           nextPutAll: '>>#';
-           nextPutAll: testSelector
+           nextPutAll: self class printString.
+       testSelector isNil
+           ifFalse: [aStream
+                       nextPutAll: '>>#';
+                       nextPutAll: testSelector].
     ]
 ]
 
diff --git a/packages/sunit/SUnitTests.st b/packages/sunit/SUnitTests.st
index d1160a1..11fbb88 100644
--- a/packages/sunit/SUnitTests.st
+++ b/packages/sunit/SUnitTests.st
@@ -276,6 +276,14 @@ if the tests are hard to write, something is probably 
wrong with the design".'>
            assert: aResult errorCount = anErrorCount
     ]
 
+    testPrintString [
+        <category: 'Testing'>
+        "Make sure that a new test can be printed"
+
+        self
+            shouldnt: [TestCase new printString] raise: Exception.
+    ]
+
     isLogging [
        <category: 'Logging'>
        ^true
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]