Pyret: adding tests directly into classes

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

Pyret: adding tests directly into classes

Andy Burnett
I have just come across the Pyret language. It looks interesting, but the part which particularly caught my interest was the way that they had built the unit tests directly into the classes, rather than having separate test classes.  

I think this is an interesting idea. It seems as though it would be easier to manage writing tests if everything were in one location. And this - might - mean that people were more likely to write tests.

Has anyone else looked at this, and have an opinion on whether it would be a good addition to Pharo 4/5/X?

Cheers
Andy
Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

Tudor Girba-2
I stumbled across this idea when Markus Gaelli chose it as a PhD topic about ten years ago (man, I'm old). The main idea was not to provide tests, but examples that happened to have assertions. The goal was twofold: (1) provide live documentation with real objects, (2) provide another way of composing tests.

The project did not really come to fruition, but I still think this is highly interesting topic. Part of the ideas were later implemented in Phexample (http://www.smalltalkhub.com/#!/~Phexample/Phexample/) and JExample (http://scg.unibe.ch/research/jexample).

Cheers,
Doru


On Sun, Nov 17, 2013 at 3:08 PM, Andy Burnett <[hidden email]> wrote:
I have just come across the Pyret language. It looks interesting, but the part which particularly caught my interest was the way that they had built the unit tests directly into the classes, rather than having separate test classes.  

I think this is an interesting idea. It seems as though it would be easier to manage writing tests if everything were in one location. And this - might - mean that people were more likely to write tests.

Has anyone else looked at this, and have an opinion on whether it would be a good addition to Pharo 4/5/X?

Cheers
Andy



--

"Every thing has its own flow"
Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

EstebanLM
In reply to this post by Andy Burnett
Hi,

It does not really matters where you put the test.
What matters is to have the tools that show them properly, and we are going in that direction. We already have ways to "jump to tests" in Nautilus, and we will continue improving that to show them together (for example).
But I do not think the tests need to be *in* the class definition to have same level of interoperation.

Esteban

On Nov 17, 2013, at 3:08 PM, Andy Burnett <[hidden email]> wrote:

> I have just come across the Pyret language. It looks interesting, but the part which particularly caught my interest was the way that they had built the unit tests directly into the classes, rather than having separate test classes.  
>
> I think this is an interesting idea. It seems as though it would be easier to manage writing tests if everything were in one location. And this - might - mean that people were more likely to write tests.
>
> Has anyone else looked at this, and have an opinion on whether it would be a good addition to Pharo 4/5/X?
>
> Cheers
> Andy


Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

Andy Burnett
In reply to this post by Andy Burnett

Doru said:
<<<
I stumbled across this idea when Markus Gaelli chose it as a PhD topic
about ten years ago (man, I'm old). The main idea was not to provide tests,
but examples that happened to have assertions. The goal was twofold: (1)
provide live documentation with real objects, (2) provide another way of
composing tests.

The project did not really come to fruition, but I still think this is
highly interesting topic. Part of the ideas were later implemented in
Phexample (http://www.smalltalkhub.com/#!/~Phexample/Phexample/) and
JExample (http://scg.unibe.ch/research/jexample).

>>>


That's really interesting. I had never heard of Phexample - so many interesting projects, so little time! - I like the approach of building on tests.  Do you know if this will work in Pharo 3?

Also, I may have misunderstood what Pyret was doing. Perhaps it is more about examples.
Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

Andy Burnett
In reply to this post by Andy Burnett
Esteban said

<<<
Hi,

It does not really matters where you put the test.
What matters is to have the tools that show them properly, and we are going in that direction. We already have ways to "jump to tests" in Nautilus, and we will continue improving that to show them together (for example).
But I do not think the tests need to be *in* the class definition to have same level of interoperation.

Esteban
>>>

I agree. The actual architecture doesn't matter. The critical factor is making it as easy as possible to write/navigate tests. I didn't know about the Nautilus features. I shall have to go and experiment.

Also, thinking about Doru's point. I wonder if we could write tests/examples in the comments section of code. It might be an interesting addition

Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

jtuchel
Hi,

the good thing about the current practice of putting tests into another
package/application is that you can separate them from your actual code
for deployment (packaging), but you can also add them to your deliverable.
If you mix code and tests, there may be good points about that, but in
the end the limiting factor is the developer's discipline/motivation.
And to some extent the quality of tools. The current state of test
runners in most Smalltalk environments is not too bad.

So I guess we need to educate people more towards writing tests, not
change the place where they belong.
Putting tests somewhere else than other Smalltalk's do would also start
build hurdles to portability of tools between them. Would be a pity,
wouldn't it?

Just my 2 cents

Joachim


Am 17.11.13 19:58, schrieb Andy Burnett:

> Esteban said
>
> <<<
> Hi,
>
> It does not really matters where you put the test.
> What matters is to have the tools that show them properly, and we are
> going in that direction. We already have ways to "jump to tests" in
> Nautilus, and we will continue improving that to show them together
> (for example).
> But I do not think the tests need to be *in* the class definition to
> have same level of interoperation.
>
> Esteban
> >>>
>
> I agree. The actual architecture doesn't matter. The critical factor
> is making it as easy as possible to write/navigate tests. I didn't
> know about the Nautilus features. I shall have to go and experiment.
>
> Also, thinking about Doru's point. I wonder if we could write
> tests/examples in the comments section of code. It might be an
> interesting addition
>


--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:[hidden email]
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1


Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

philippeback
Agreed.

And the more I use Pharo, the more I am looking into tests (especially "Debug Test" to understand how things do work) and writing tests first.

That's not a natural thing to do in other environments but feels so great to do in Pharo.

(Writing this after having looked at a ton of Seaside and Magritte tests :-) ).

The image isn't regular when it comes to tests with some things being Tests-XXX at the end and KernelTests-XXX for example.

And for my project I do have Project-Tests-XXX which keeps them close to the project categories (otherwise, I have to scroll too much [groups: good!]). It also helps to put everything in a single Project-XXX package when needed (which happened).

BTW, how can one use the "Autotest" feature I saw demoed somewhere? Is that Moose-related? 

Phil


On Mon, Nov 18, 2013 at 8:20 AM, [hidden email] <[hidden email]> wrote:
Hi,

the good thing about the current practice of putting tests into another package/application is that you can separate them from your actual code for deployment (packaging), but you can also add them to your deliverable.
If you mix code and tests, there may be good points about that, but in the end the limiting factor is the developer's discipline/motivation. And to some extent the quality of tools. The current state of test runners in most Smalltalk environments is not too bad.

So I guess we need to educate people more towards writing tests, not change the place where they belong.
Putting tests somewhere else than other Smalltalk's do would also start build hurdles to portability of tools between them. Would be a pity, wouldn't it?

Just my 2 cents

Joachim


Am 17.11.13 19:58, schrieb Andy Burnett:
Esteban said

<<<
Hi,

It does not really matters where you put the test.
What matters is to have the tools that show them properly, and we are going in that direction. We already have ways to "jump to tests" in Nautilus, and we will continue improving that to show them together (for example).
But I do not think the tests need to be *in* the class definition to have same level of interoperation.

Esteban
>>>

I agree. The actual architecture doesn't matter. The critical factor is making it as easy as possible to write/navigate tests. I didn't know about the Nautilus features. I shall have to go and experiment.

Also, thinking about Doru's point. I wonder if we could write tests/examples in the comments section of code. It might be an interesting addition



--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:[hidden email]
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: <a href="tel:%2B49%207141%2056%2010%2086%200" value="+4971415610860" target="_blank">+49 7141 56 10 86 0         Fax: <a href="tel:%2B49%207141%2056%2010%2086%201" value="+4971415610861" target="_blank">+49 7141 56 10 86 1




Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

camille teruel
In reply to this post by Tudor Girba-2

On 17 nov. 2013, at 15:16, Tudor Girba <[hidden email]> wrote:

I stumbled across this idea when Markus Gaelli chose it as a PhD topic about ten years ago (man, I'm old). The main idea was not to provide tests, but examples that happened to have assertions. The goal was twofold: (1) provide live documentation with real objects, (2) provide another way of composing tests.

The project did not really come to fruition, but I still think this is highly interesting topic. Part of the ideas were later implemented in Phexample (http://www.smalltalkhub.com/#!/~Phexample/Phexample/) and JExample (http://scg.unibe.ch/research/jexample).

Cheers,
Doru

There was a presentation of the Pyret language at SCRIPT workshop last week. 
This way of coupling unit tests with functions is indeed interesting.
One the one hand I feel it's like a mixing of concerns, on the other hand it's push unit-tests into the language.
The funny part is that the examples provided are used to type the function:

fun id(x):
x
where:
id(3) is 3
id("bla") is "bla"
end

is typed as 'a -> 'a whereas:

fun id(x):
x
where:
id(3) is 3
end

is typed as int -> int


On Sun, Nov 17, 2013 at 3:08 PM, Andy Burnett <[hidden email]> wrote:
I have just come across the Pyret language. It looks interesting, but the part which particularly caught my interest was the way that they had built the unit tests directly into the classes, rather than having separate test classes.  

I think this is an interesting idea. It seems as though it would be easier to manage writing tests if everything were in one location. And this - might - mean that people were more likely to write tests.

Has anyone else looked at this, and have an opinion on whether it would be a good addition to Pharo 4/5/X?

Cheers
Andy



--

"Every thing has its own flow"

Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

Esteban A. Maringolo
I don't like having the Unit Tests so coupled with the code.

Many times I implement Unit Tests that doesn't match 1:1 with a class.
It is... the TestCase subclass doesn't have a corresponding class (eg.
SomeFeatureTest, with no SomeFeature class in the system).


Regards,

Esteban A. Maringolo


2013/11/18 Camille Teruel <[hidden email]>:

>
> On 17 nov. 2013, at 15:16, Tudor Girba <[hidden email]> wrote:
>
> I stumbled across this idea when Markus Gaelli chose it as a PhD topic about
> ten years ago (man, I'm old). The main idea was not to provide tests, but
> examples that happened to have assertions. The goal was twofold: (1) provide
> live documentation with real objects, (2) provide another way of composing
> tests.
>
> The project did not really come to fruition, but I still think this is
> highly interesting topic. Part of the ideas were later implemented in
> Phexample (http://www.smalltalkhub.com/#!/~Phexample/Phexample/) and
> JExample (http://scg.unibe.ch/research/jexample).
>
> Cheers,
> Doru
>
>
> There was a presentation of the Pyret language at SCRIPT workshop last week.
> This way of coupling unit tests with functions is indeed interesting.
> One the one hand I feel it's like a mixing of concerns, on the other hand
> it's push unit-tests into the language.
> The funny part is that the examples provided are used to type the function:
>
> fun id(x):
> x
> where:
> id(3) is 3
> id("bla") is "bla"
> end
>
> is typed as 'a -> 'a whereas:
>
> fun id(x):
> x
> where:
> id(3) is 3
> end
>
> is typed as int -> int
>
>
> On Sun, Nov 17, 2013 at 3:08 PM, Andy Burnett
> <[hidden email]> wrote:
>>
>> I have just come across the Pyret language. It looks interesting, but the
>> part which particularly caught my interest was the way that they had built
>> the unit tests directly into the classes, rather than having separate test
>> classes.
>>
>> I think this is an interesting idea. It seems as though it would be easier
>> to manage writing tests if everything were in one location. And this - might
>> - mean that people were more likely to write tests.
>>
>> Has anyone else looked at this, and have an opinion on whether it would be
>> a good addition to Pharo 4/5/X?
>>
>> Cheers
>> Andy
>
>
>
>
> --
> www.tudorgirba.com
>
> "Every thing has its own flow"
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

camille teruel

On 18 nov. 2013, at 13:07, Esteban A. Maringolo <[hidden email]> wrote:

> I don't like having the Unit Tests so coupled with the code.
>
> Many times I implement Unit Tests that doesn't match 1:1 with a class.
> It is... the TestCase subclass doesn't have a corresponding class (eg.
> SomeFeatureTest, with no SomeFeature class in the system).

IMO, you're talking about functional tests, not unit tests.
While a unit test is done in isolation and is concerned with one "unit" (typically a method),
an acceptance test tests a feature of your application that will typically crosscut many units.
In Pyret, they have another clause "check" for that purpose.

> Regards,
>
> Esteban A. Maringolo
>
>
> 2013/11/18 Camille Teruel <[hidden email]>:
>>
>> On 17 nov. 2013, at 15:16, Tudor Girba <[hidden email]> wrote:
>>
>> I stumbled across this idea when Markus Gaelli chose it as a PhD topic about
>> ten years ago (man, I'm old). The main idea was not to provide tests, but
>> examples that happened to have assertions. The goal was twofold: (1) provide
>> live documentation with real objects, (2) provide another way of composing
>> tests.
>>
>> The project did not really come to fruition, but I still think this is
>> highly interesting topic. Part of the ideas were later implemented in
>> Phexample (http://www.smalltalkhub.com/#!/~Phexample/Phexample/) and
>> JExample (http://scg.unibe.ch/research/jexample).
>>
>> Cheers,
>> Doru
>>
>>
>> There was a presentation of the Pyret language at SCRIPT workshop last week.
>> This way of coupling unit tests with functions is indeed interesting.
>> One the one hand I feel it's like a mixing of concerns, on the other hand
>> it's push unit-tests into the language.
>> The funny part is that the examples provided are used to type the function:
>>
>> fun id(x):
>> x
>> where:
>> id(3) is 3
>> id("bla") is "bla"
>> end
>>
>> is typed as 'a -> 'a whereas:
>>
>> fun id(x):
>> x
>> where:
>> id(3) is 3
>> end
>>
>> is typed as int -> int
>>
>>
>> On Sun, Nov 17, 2013 at 3:08 PM, Andy Burnett
>> <[hidden email]> wrote:
>>>
>>> I have just come across the Pyret language. It looks interesting, but the
>>> part which particularly caught my interest was the way that they had built
>>> the unit tests directly into the classes, rather than having separate test
>>> classes.
>>>
>>> I think this is an interesting idea. It seems as though it would be easier
>>> to manage writing tests if everything were in one location. And this - might
>>> - mean that people were more likely to write tests.
>>>
>>> Has anyone else looked at this, and have an opinion on whether it would be
>>> a good addition to Pharo 4/5/X?
>>>
>>> Cheers
>>> Andy
>>
>>
>>
>>
>> --
>> www.tudorgirba.com
>>
>> "Every thing has its own flow"
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

jtuchel
In reply to this post by Esteban A. Maringolo
Esteban,

good point. I use Tests sometimes as a mixture of design help and living
documentation. And there, test cases almost never match classes 1:1.
And I also think that is a good thing. Especially when it comes to
refactoring and major redesign where the API of some entry points to a
certain functional unit must not be changed.

One could now start a new discussion on whether this use case is "unit
testing" or now, but I guess we can be glad when people write any kind
of test ;-)
Not every thing that should be improved can be improved by changing
tools. Sometimes it really is a people thing.


Joachim

Am 18.11.13 13:07, schrieb Esteban A. Maringolo:

> I don't like having the Unit Tests so coupled with the code.
>
> Many times I implement Unit Tests that doesn't match 1:1 with a class.
> It is... the TestCase subclass doesn't have a corresponding class (eg.
> SomeFeatureTest, with no SomeFeature class in the system).
>
>
> Regards,
>
> Esteban A. Maringolo
>
>
> 2013/11/18 Camille Teruel <[hidden email]>:
>> On 17 nov. 2013, at 15:16, Tudor Girba <[hidden email]> wrote:
>>
>> I stumbled across this idea when Markus Gaelli chose it as a PhD topic about
>> ten years ago (man, I'm old). The main idea was not to provide tests, but
>> examples that happened to have assertions. The goal was twofold: (1) provide
>> live documentation with real objects, (2) provide another way of composing
>> tests.
>>
>> The project did not really come to fruition, but I still think this is
>> highly interesting topic. Part of the ideas were later implemented in
>> Phexample (http://www.smalltalkhub.com/#!/~Phexample/Phexample/) and
>> JExample (http://scg.unibe.ch/research/jexample).
>>
>> Cheers,
>> Doru
>>
>>
>> There was a presentation of the Pyret language at SCRIPT workshop last week.
>> This way of coupling unit tests with functions is indeed interesting.
>> One the one hand I feel it's like a mixing of concerns, on the other hand
>> it's push unit-tests into the language.
>> The funny part is that the examples provided are used to type the function:
>>
>> fun id(x):
>> x
>> where:
>> id(3) is 3
>> id("bla") is "bla"
>> end
>>
>> is typed as 'a -> 'a whereas:
>>
>> fun id(x):
>> x
>> where:
>> id(3) is 3
>> end
>>
>> is typed as int -> int
>>
>>
>> On Sun, Nov 17, 2013 at 3:08 PM, Andy Burnett
>> <[hidden email]> wrote:
>>> I have just come across the Pyret language. It looks interesting, but the
>>> part which particularly caught my interest was the way that they had built
>>> the unit tests directly into the classes, rather than having separate test
>>> classes.
>>>
>>> I think this is an interesting idea. It seems as though it would be easier
>>> to manage writing tests if everything were in one location. And this - might
>>> - mean that people were more likely to write tests.
>>>
>>> Has anyone else looked at this, and have an opinion on whether it would be
>>> a good addition to Pharo 4/5/X?
>>>
>>> Cheers
>>> Andy
>>
>>
>>
>> --
>> www.tudorgirba.com
>>
>> "Every thing has its own flow"
>>
>>
>


--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:[hidden email]
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1


Reply | Threaded
Open this post in threaded view
|

Re: Pyret: adding tests directly into classes

Stéphane Ducasse
+1
>
> One could now start a new discussion on whether this use case is "unit testing" or now, but I guess we can be glad when people write any kind of test ;-)
> Not every thing that should be improved can be improved by changing tools. Sometimes it really is a people thing.