The Inbox: SUnit-cmm.90.mcz

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

The Inbox: SUnit-cmm.90.mcz

commits-2
A new version of SUnit was added to project The Inbox:
http://source.squeak.org/inbox/SUnit-cmm.90.mcz

==================== Summary ====================

Name: SUnit-cmm.90
Author: cmm
Time: 4 January 2013, 3:33:36.616 pm
UUID: 8533f0b4-2587-412b-b465-4ad7f20331d0
Ancestors: SUnit-ul.89

- Do not wipe out pre-initialized state on TestCases.  Tests do not need to be prevented from running more than once if proper setUp/tearDown methods are present.

=============== Diff against SUnit-ul.89 ===============

Item was changed:
  ----- Method: TestCase>>debug (in category 'running') -----
  debug
+ self resources do:
+ [ : res | res isAvailable ifFalse: [ ^ res signalInitializationError ] ].
+ [ self runCase ] ensure:
+ [ self resources do:
+ [ : each | each reset ] ]!
- self resources do: [:res |
- res isAvailable ifFalse: [^res signalInitializationError]].
- [(self class selector: testSelector) runCase]
- ensure: [self resources do: [:each | each reset]]
- !


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: SUnit-cmm.90.mcz

Chris Muller-3
I need to set up various special state on all tests of a specialized
Suite during initialization of the Suite.  But after creating the
tests, SUnit then promptly throws them all away which is not only
wasteful it loses all of my needed additional-state).

setUp and tearDown are intended to, well, set up and tear down any
test.  Any test that cannot "run again" is broken because it means its
setUp and tearDown methods don't do the job they're supposed to.

If no objections, I will push this to trunk and delete the
#testRanOnlyOnce test.

Thanks,
  Chris

On Fri, Jan 4, 2013 at 3:33 PM,  <[hidden email]> wrote:

> A new version of SUnit was added to project The Inbox:
> http://source.squeak.org/inbox/SUnit-cmm.90.mcz
>
> ==================== Summary ====================
>
> Name: SUnit-cmm.90
> Author: cmm
> Time: 4 January 2013, 3:33:36.616 pm
> UUID: 8533f0b4-2587-412b-b465-4ad7f20331d0
> Ancestors: SUnit-ul.89
>
> - Do not wipe out pre-initialized state on TestCases.  Tests do not need to be prevented from running more than once if proper setUp/tearDown methods are present.
>
> =============== Diff against SUnit-ul.89 ===============
>
> Item was changed:
>   ----- Method: TestCase>>debug (in category 'running') -----
>   debug
> +       self resources do:
> +               [ : res | res isAvailable ifFalse: [ ^ res signalInitializationError ] ].
> +       [ self runCase ] ensure:
> +               [ self resources do:
> +                       [ : each | each reset ] ]!
> -       self resources do: [:res |
> -               res isAvailable ifFalse: [^res signalInitializationError]].
> -       [(self class selector: testSelector) runCase]
> -               ensure: [self resources do: [:each | each reset]]
> -                       !
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: SUnit-cmm.90.mcz

Colin Putney-3



On Fri, Jan 4, 2013 at 4:38 PM, Chris Muller <[hidden email]> wrote:
I need to set up various special state on all tests of a specialized
Suite during initialization of the Suite.  But after creating the
tests, SUnit then promptly throws them all away which is not only
wasteful it loses all of my needed additional-state).

setUp and tearDown are intended to, well, set up and tear down any
test.  Any test that cannot "run again" is broken because it means its
setUp and tearDown methods don't do the job they're supposed to.

If no objections, I will push this to trunk and delete the
#testRanOnlyOnce test.

I don't know the details of your use case, but isn't this what TestResources are for? Why are you customizing the initialization of a Suite?

Colin


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: SUnit-cmm.90.mcz

Chris Muller-3
>> I need to set up various special state on all tests of a specialized
>> Suite during initialization of the Suite.  But after creating the
>> tests, SUnit then promptly throws them all away which is not only
>> wasteful it loses all of my needed additional-state).
>>
>> setUp and tearDown are intended to, well, set up and tear down any
>> test.  Any test that cannot "run again" is broken because it means its
>> setUp and tearDown methods don't do the job they're supposed to.
>>
>> If no objections, I will push this to trunk and delete the
>> #testRanOnlyOnce test.
>
> I don't know the details of your use case, but isn't this what TestResources
> are for? Why are you customizing the initialization of a Suite?

SUnit provides #suiteClass to allow one to create their own custom
TestSuite subclasses.  This is *all that's needed* for SUnit to
accomodate the need for resources not to mention many many other
use-cases.

By contrast, the TestResource implementation is just plain bad design.
 Very bad.  For being overly complex (just look at
TestCase>>#resources), for the added dependencies on TestResource api
(#isAvailable, #reset), for the required overrides on the class-side
of the TestCase just to tell it the class names of the TestResources
(Geez!!), for employing global state to implement it --- what, oh
what, do I get for all of these negatives?

One crummy accessor, #resources which is.... (drum roll please) a Set!
 Huh?!  I guess that means I need to detect through it to look for
particular resources by class type?  Baaaaad.

Which is why I prefer to just use good ol'e OO:  Take advantage of
SUnits hook for defining my own TestSuite subclass with its own named
inst-vars for what it needs (resources or whatnot), and send #setUp
and #tearDown to it so it is consistent with treatment of TestCases
and all-around smaller and simpler.

But I do need for SUnit to not subvert its own hooks it provides for
folks doing it this way, which it does without this patch.