Phexample should methods

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

Phexample should methods

Stefan Marr-3
While wondering how to simply support Pharo 1.4 and Pharo 2.0 at the same time, I noticed something I didn't think about before.

Phexample does use the following code to identify what a test method is:

        each numArgs isZero and:
                [ (each asLowercase includesSubString: 'should')

Note that it is #includesSubString, in contrast to #beginsWith:.
Is that on purpose?
Is this feature supposed to be used?

That gives rise to example-driven testing ala:

Foo >> #barShouldBeSomething

So far, I tried to avoid that, and make examples that are really focused on one specific subject, which is represented by the class name.

Any opinions on that?

Best regards
Stefan

PS: It is also inconsistent with Phexample's own #isTest: implementation, which uses #beginsWith:

--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax:   +32 2 629 3525


Reply | Threaded
Open this post in threaded view
|

Re: Phexample should methods

stephane ducasse

On Feb 10, 2013, at 9:39 PM, Stefan Marr <[hidden email]> wrote:

> While wondering how to simply support Pharo 1.4 and Pharo 2.0 at the same time, I noticed something I didn't think about before.
>
> Phexample does use the following code to identify what a test method is:
>
> each numArgs isZero and:
> [ (each asLowercase includesSubString: 'should')
>
> Note that it is #includesSubString, in contrast to #beginsWith:.
> Is that on purpose?
> Is this feature supposed to be used?

I have no idea.
I was confused by the fact that should beTrue returns nil and other.
And I was trapped with the interaction with Job progress.

> That gives rise to example-driven testing ala:
>
> Foo >> #barShouldBeSomething
>
> So far, I tried to avoid that, and make examples that are really focused on one specific subject, which is represented by the class name.
>
> Any opinions on that?
>
> Best regards
> Stefan
>
> PS: It is also inconsistent with Phexample's own #isTest: implementation, which uses #beginsWith:
>
> --
> Stefan Marr
> Software Languages Lab
> Vrije Universiteit Brussel
> Pleinlaan 2 / B-1050 Brussels / Belgium
> http://soft.vub.ac.be/~smarr
> Phone: +32 2 629 2974
> Fax:   +32 2 629 3525
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Phexample should methods

Sean P. DeNigris
Administrator
In reply to this post by Stefan Marr-3
This is great. I love the matchers in Phexample (although I'm not sold on the test dependency part. I think dependent tests should be skipped, not failed... yet I digress...)

Stefan Marr-3 wrote
Note that it is #includesSubString, in contrast to #beginsWith:.
Is that on purpose?
This means that should can't appear in any non-test selector in a test class. As cool as #barShouldBeSomething looks, I don't think it's worth the confusion. And as you alluded to, it might encourage poor test design

Stefan Marr-3 wrote
PS: It is also inconsistent with Phexample's own #isTest: implementation, which uses #beginsWith:
There should be one place in the image that defines what a test is. I'm guessing it would be packaged with SUnit, then Nautilus, Phexample, etc can refer to or alter it and get the change everywhere.

HTH,
Sean
Cheers,
Sean