The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Enhancing SUnitToo

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Enhancing SUnitToo Posted: Jul 6, 2006 8:49 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Enhancing SUnitToo
Feed Title: David Buck - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/buck-rss.xml
Feed Description: Smalltalk can do that
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From David Buck - Blog

Advertisement

I like Travis Griggs' SUnitToo package and the corresponding browser extension ExtraRBForSUnitToo. One thing I always disliked about SUnit in general, though, is that you had to name your test methods to start with the word "test". This means that if you want to remove a test from the test suite for some reason, you have to rename it.

So, I decided to take the bull by the horns and do something about it. First, I created a new pragma for subclasses of TestCase.

TestCase class:
 
testPragmas
   <pragmas: #instance>
 	^#(#test)
 

Now, we can test for the attribute #test to determine if methods are testcases. To do this, we need to change a few methods.

TestCase class:
 
testSelectors
 	^self selectors select: [:each |
  		('test*' match: each)	or:
  			[(self findSelector: each) last attributes
 				ifNil: [false]
 				ifNotNil: [:attributes | attributes includesKey: #test]]] 
 
TestCase class:
 
allTestSelectors
 	^self allSelectors select: [:each | ('test*' match: each)	or:
  			[(self findSelector: each) last attributes
 				ifNil: [false]
 				ifNotNil: [:attributes | attributes includesKey: #test]]]
 
CompiledMethod:
 
isTestCaseMethod
 	^(self mclass inheritsFrom: SUnit.TestCase)
  		and: [('test*' match: self selector) or:
  			[(self mclass findSelector: self selector) last attributes
 				ifNil: [false]
 				ifNotNil: [:attributes | attributes includesKey: #test]]]
 

That's it. Now, you can write a testcase with a normal method name. To mark it as a testcase, you just add a <test> pragma to the method.

MyTestClass
 
openConnectionAndSendMessage
   <test>
   "...code for the test..." 
 

I'd be happy to submit these changes to the Cincom public Store repository if there's interest.

Read: Enhancing SUnitToo

Topic: Paying the Rent Previous Topic   Next Topic Topic: Making your point

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use