[Pharo-dev] How to test the same behavior with different data

Noury Bouraqadi bouraqadi at gmail.com
Mon Oct 7 13:51:55 EDT 2013


Hi,

Just published my blog post on ParametrizedTests that is a proposal that addresses the question we have been discussing in this thread.
http://car.mines-douai.fr/2013/10/parametrized-tests/

I believe it can be easily integrated into Pharo's SUnit.

Noury

On 25 sept. 2013, at 12:38, Frank Shearar wrote:

> Hi Noury,
> 
> At the moment it's hard-coded to 100 data points. It'd be better to
> pull that out into some kind of configuration object though.
> 
> frank
> 
> On 25 September 2013 11:19, Noury Bouraqadi <bouraqadi at gmail.com> wrote:
>> Hi Frank,
>> 
>> This sounds cool. But, how do you decide how many data you generate per test run ?
>> 
>> Noury
>> On 23 sept. 2013, at 11:19, Frank Shearar wrote:
>> 
>>> I played around with a combination of data driven testing and random
>>> data generation a while back:
>>> * http://www.lshift.net/blog/2011/09/13/checking-squeak-quickly
>>> * http://www.squeaksource.com/SqueakCheck/
>>> 
>>> There is a ConfigurationOf there. It integrates with SUnit by adding a
>>> new kind of TestCase that knows how to run theories, identified by
>>> pragmas. It also features the recording of a counterexample to your
>>> theory by generating a normal test method on the relevant TestCase
>>> subclass.
>>> 
>>> I haven't touched the code in a while, but if there's interest I'd be
>>> happy to hack on it once more.
>>> 
>>> frank
>>> 
>>> On 22 September 2013 21:43, laurent laffont <laurent.laffont at gmail.com> wrote:
>>>> Hi,
>>>> 
>>>> in phpunit there's a @dataProvider annotation, so one method returns a
>>>> several data sets for a test method. I'm not sure that's the best design but
>>>> it's nice to have one unit test result per data set. See
>>>> http://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers
>>>> 
>>>> 
>>>> Translating the example to Pharo that should give something like:
>>>> 
>>>> TestCase subclass: #DataTest
>>>> 
>>>> DataTest>>testAdd: a to: b shouldAnswer: c
>>>> <dataProvider: #provider>
>>>> self assert: c equals: a + b
>>>> 
>>>> DataTest>>provider
>>>> ^ { {0. 0. 0}.
>>>>      {1. 0. 1}.
>>>>      {0. 1. 1}.
>>>>      {1. 2. 3} }
>>>> 
>>>> It may not be to difficult to implement in SUnit. What do you think about
>>>> this ?
>>>> 
>>>> Laurent
>>>> 
>>>> 
>>>> On Sat, Sep 21, 2013 at 1:47 PM, Jan Vrany <jan.vrany at fit.cvut.cz> wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> I actually already thought on this as I have similar problems.
>>>>> So far I just create a bunch of tests, passing the actual set of
>>>>> parameters to a common test method as message arguments.
>>>>> 
>>>>> For different framework (not SUnit, but similar spirit), I introduced a
>>>>> notion of "parameter", each having a domain. When running test, the runner
>>>>> computes all possible combinations of parameter values and run the test on
>>>>> each such combination. I would like to have something similar
>>>>> in SUnit, but there are some issues. This is the feature I would like to
>>>>> see in SUnit 6.x, but I/we have to finish 5.0 first - I wonder if I ever
>>>>> find a time to do push it :-(
>>>>> 
>>>>> 
>>>>> On 21/09/13 11:06, Noury Bouraqadi wrote:
>>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>> Last ESUG I attended the cool katas session organized by Stephan
>>>>>> Eggermont and Laurent Laffont.
>>>>>> That was a good opportunity to step back and think about my TDD practices
>>>>>> .
>>>>>> 
>>>>>> To experiment with the style proposed by Laurent, I started writing tests
>>>>>> for a pong.
>>>>>> I ended up having groups of nearly identical tests:
>>>>>> -they use exactly the same objects, send the same messages,
>>>>>> -but they differ only by values.
>>>>>> 
>>>>>> An example, is testing the motion of the ball towards different
>>>>>> directions or collisions with obstacles at different locations or speeds.
>>>>>> 
>>>>>> Now, I wonder what is the best way to express those similar tests?
>>>>>> 
>>>>>> In a short discussion before I leave, Stephane told me about tables of
>>>>>> values. It seem that there is such a support in the ruby world in the
>>>>>> cucumber framework. Do we have anything similar in Smalltalk world?
>>>>>> 
>>>>>> BTW, the full ESUG conference was great. Thanx to local organizers, and
>>>>>> all people that contributed to make it a success.
>>>>>> 
>>>>>> Thanx,
>>>>>> Noury
>>>>>> Ecole des Mines de Douai
>>>>>> http://car.mines-douai.fr/noury
>>>>>> --
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>> 
>> 
>> Noury
>> --
>> http://twitter.com/#!/NouryBouraqadi
>> http://car.mines-douai.fr/noury
>> 
>> Noury Bouraqadi
>> Ecole des Mines de Douai
>> http://car.mines-douai.fr/noury
>> --
>> 
>> 
>> 
>> 
>> Afin de contribuer au respect de l'environnement,
>> merci de n'imprimer ce courriel qu'en cas de necessite
>> 
>> Please consider the environment before you print
>> 
>> 
>> 
>> 
> 

Noury
--
http://twitter.com/#!/NouryBouraqadi
http://car.mines-douai.fr/noury

Noury Bouraqadi
Ecole des Mines de Douai
http://car.mines-douai.fr/noury
--







More information about the Pharo-dev mailing list