How to test SASE?

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

How to test SASE?

Esteban A. Maringolo-3
Hi,

        I'm having problems doing some unit tests using the SASE extensions.

        If I subscribe the test to the event, it receives the message send
with #fooEventMethod selector, but the tests fails (with an
exclamation icon in the SUnit browser).

        If I subscribe container to itself, the test passes.

        I guess I'm using SASE Testing wrong. I've always used it to test
presenters and other related stuff, but never the events between
objects.

ContainerTest>>testAddSubstanceEvents
   "Tests the addition of a substance to the container."

   | substance |
   substance := Substance newNamed: 'Test substance'.
   container := Container newNamed: 'Test container'.
   container when: #substancesChanged send: #fooEventMethod to: self.
   self
     should: [container addSubstance: substance amount: 11kg]
     trigger: #substancesChanged
     against: self


ContainerTest>>fooEventMethod
    "Do nothing"

       
Best Regards.


Reply | Threaded
Open this post in threaded view
|

Re: How to test SASE?

Andy Bower-3
Esteban,

Shouldn't that be:

self
   should: [container addSubstance: substance amount: 11kg]
   trigger: #substancesChanged
   against: container.

since it is (presumably) the Container class thaet triggers the
#substancesChanged event when the #addSubstance:amount: method is
called. Also, unless you need it for something in particular you don't
actually have to subscibe to the #substancesChanged event in you test.
I'd probably just write it like:


ContainerTest>>testAddSubstanceEvents
  "Tests the addition of a substance to the container."

  | substance |
  substance := Substance newNamed: 'Test substance'.
  container := Container newNamed: 'Test container'.
  self
    should: [container addSubstance: substance amount: 11kg]
    trigger: #substancesChanged
    against: container.

Best Regards,

--
Andy Bower
Dolphin Support
www.object-arts.com


Reply | Threaded
Open this post in threaded view
|

Re: How to test SASE?

Esteban A. Maringolo-3
Hi Andy,

        It worked OK, thanks for the explanation.

--
Esteban

Andy Bower escribió:
> since it is (presumably) the Container class thaet triggers the
> #substancesChanged event when the #addSubstance:amount: method is
> called. Also, unless you need it for something in particular you don't
> actually have to subscibe to the #substancesChanged event in you test.
> I'd probably just write it like:

> ContainerTest>>testAddSubstanceEvents
 > SNIP!