[PATCH] sunit: Fix TestCase new printString signals an exception

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

[PATCH] sunit: Fix TestCase new printString signals an exception

Holger Freyther
From: Holger Hans Peter Freyther <[hidden email]>

testSelector is nil before the execution of the testcase.

2012-08-03  Holger Hans Peter Freyther  <[hidden email]>

        * 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  <[hidden email]>
+
+ * packages/sunit/SUnit.st: Only print the testSelector if it
+ is not nil.
+ * packages/sunit/SUnitTest.st: Add #testPrintString.
+
 2010-12-04  Paolo Bonzini  <[hidden email]>
 
  * 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


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] sunit: Fix TestCase new printString signals an exception

Paolo Bonzini-2
Il 04/08/2012 12:51, Holger Hans Peter Freyther ha scritto:
> From: Holger Hans Peter Freyther <[hidden email]>
>
> testSelector is nil before the execution of the testcase.
>
> 2012-08-03  Holger Hans Peter Freyther  <[hidden email]>
>
> * packages/sunit/SUnit.st: Only print the testSelector if it
> is not nil.
> * packages/sunit/SUnitTest.st: Add #testPrintString.

Can you use #display: instead?

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] sunit: Fix TestCase new printString signals an exception

Holger Freyther
On Sat, Aug 04, 2012 at 07:12:13PM +0200, Paolo Bonzini wrote:
>
> Can you use #display: instead?

I don't fully follow. Use display for the whole testcase or
just for the selector part? 'testSelector' is a Symbol and not
the selector. 'TestCase>>nil' is the output you would want?

holger

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] sunit: Fix TestCase new printString signals an exception

Paolo Bonzini-2
Il 04/08/2012 21:46, Holger Hans Peter Freyther ha scritto:
>> > Can you use #display: instead?
> I don't fully follow. Use display for the whole testcase or
> just for the selector part? 'testSelector' is a Symbol and not
> the selector. 'TestCase>>nil' is the output you would want?

Yes, thanks.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk