SUnit Resource Browser

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

SUnit Resource Browser

Sebastián Sastre
Hi all,

    I want to understad how to take advantage of the SUnit Resource Browser.
I do use unit test but I haven't found the prupose and methodology of the
test suites. How do I use these test? any lectures to recommend me?

    Other thing. I saw that with the SUnit Browser you can select the test
you don't want to work with at that time, press delete so they dissapear, so
you can focus on the relevant test. I have several unit test in the SUnit
Browser, lest say 50, and I some times I want to work only with 12 of these,
so I delete the other 38. But soon after when for some reason I need to
reset the test, all 50 are again on this browser. As to make some Test
Driven Development this can occur very often, I wonder how can I make the
reset of the relevant test (the 12 ones) and not all of them (the 50 ones)?

    thanks,

Seb


Reply | Threaded
Open this post in threaded view
|

Re: SUnit Resource Browser

Chris Uppal-3
Sebastián Sastre wrote:

> As to make some
> Test Driven Development this can occur very often, I wonder how can I
> make the reset of the relevant test (the 12 ones) and not all of them
> (the 50 ones)?

One way would be to define a class-side method on your test class

    allTestSelectors
        | category skip |
        category := MethodCategory name: 'don''t test (today)'.
        skip := self selectorsInCategory: category.
        ^ super allTestSelectors asSet - skip.

And then put any test methods that weren't relevant into the "don't test
(today)" method category.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: SUnit Resource Browser

Schwab,Wilhelm K
In reply to this post by Sebastián Sastre
Sebastián,

>     I want to understad how to take advantage of the SUnit Resource Browser.
> I do use unit test but I haven't found the prupose and methodology of the
> test suites. How do I use these test? any lectures to recommend me?

Yes; Google will turn up some pdf files, including one by (I think) Kent
Beck that does a nice introduction.  The basics of testing non-graphical
code are quite simple.

My Gode Generator goodie includes something that will help with the
mechanics.  Don't get too excited.  It does not actually write the tests
- it only gets you going in the right direction.  Install it, activate
the extension (see the class side of the extension class itself), and
then open a CHB and look at the bottom of the method list context menu.
  The Generate UnitTest... command will open a previewer on proposed
chunks for a suitable test class and test selector; it also give stubs
for start up and tear down methods.  Compile what you you want, and note
the previewer's browse from image command - it will help you find the
new code.  There is also a way to set a preferred test case class should
the default names be inconvenient.

Ok, so much for making it easy to do.  Now you need to know what to
write in those methods.  That's where Google enters.  I posted a
"typical" test just yesterday.  There are tests in the base system, and
once you use #should:, #should:raise:, etc. a few times, you'll be in
great shape.


>     Other thing. I saw that with the SUnit Browser you can select the test
> you don't want to work with at that time, press delete so they dissapear, so
> you can focus on the relevant test. I have several unit test in the SUnit
> Browser, lest say 50, and I some times I want to work only with 12 of these,
> so I delete the other 38. But soon after when for some reason I need to
> reset the test, all 50 are again on this browser.

Let me start by saying that the SUnit Browser is slick.  It is _so_
slick that it lead me to dump my own testing tool that I had used for a
long time (in computer terms anyway).  However, it is a little buggy.
Sometimes it gives empty lists on selection changes (clicking on
something else and returning will fix it), and the reset behavior is
most unfriendly as you have noted; the latter is probably more a point
of design vs. a defect.  Another thing I would like to see is it simply
preserve the selection on reset.  Note that I could probably get it to
do it with five or ten minutes of work.  However, I have noted that
making a change like that will usually cause a new release of something
to occur in a matter of two weeks or less ;)   Hmmmm.  D6 anyone??? :)


 > As to make some Test
> Driven Development this can occur very often, I wonder how can I make the
> reset of the relevant test (the 12 ones) and not all of them (the 50 ones)?

You might try my Acme Class Browser goodie.  In addition to being a nice
way to limit the contents of the CHB (note the drag and drop features
for adding to filters), it will create test cases that might suite your
needs.  Note the two sets of buttons CHB/Package/Tests buttons.  The
left set applies to the selected filter set (left) list; the right set
applies to the (multiple) selection in the filter (right) list.

Failing that, you could see how it creates test suites and roll your own.

In the early stages, I often put a comment such as

     "
        ThisOrThatTest new testSomething.
     "

in test methods that are new or likely to give me trouble.  When I
expect a test to fail, a do-it is lot less cumbersome than navigating in
the sunit browser, especially if I am setting breakpoints in the test
case.  When failures are rare events, the browser is the way to go.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: SUnit Resource Browser

Sebastián Sastre
In reply to this post by Chris Uppal-3
Probably I don't make my self clear enough.
I have 50 TestCase subclasses, each one of these have the methods with the
tests (average 5 o 8 testMethod per class), so I wanted to work with only a
few TestCase class at the time.

Right now I've managed to modify the SUnitBrowser to make this feature work.

Basically I patched this method:

SUnitBrowserModel>>buildSelectedList
| newSuite items tests |

items := listItems collect:[:e| e name].

self listItems: OrderedCollection new.

self builder isNil

    ifTrue: [self builder: self caseClass].

newSuite := self builder buildSuite.

tests := items

    with: newSuite tests

    whenMatch:[:ansCol :local :foreign|

        ansCol add: foreign.

        ansCol remove: local ]

    comparisionBlock:[:local :foreign| foreign name = local ].


self suite: (newSuite tests: tests).

self suite isNil ifTrue: [^self].

self testResult clear.

self

resetListItems;

signalResetList

Note the message #with: aCollection whenMatch: aBlock comparisionBlock:
aComparisionBlock
is an extension I've made some time ago to felexibly merge collections

best regards,

Seb



"Chris Uppal" <[hidden email]> escribió en el
mensaje news:[hidden email]...

> Sebastián Sastre wrote:
>
>> As to make some
>> Test Driven Development this can occur very often, I wonder how can I
>> make the reset of the relevant test (the 12 ones) and not all of them
>> (the 50 ones)?
>
> One way would be to define a class-side method on your test class
>
>    allTestSelectors
>        | category skip |
>        category := MethodCategory name: 'don''t test (today)'.
>        skip := self selectorsInCategory: category.
>        ^ super allTestSelectors asSet - skip.
>
> And then put any test methods that weren't relevant into the "don't test
> (today)" method category.
>
>    -- chris
>
>