[Pharo-users] fast subclassing/class creation in tests

Robert Withers robert.w.withers at gmail.com
Sat Oct 24 18:29:01 EDT 2015


Extend Pharo byte codes to support Newspeak namespaces. #justsayin

---
robert

> On Oct 24, 2015, at 6:22 PM, Nicolai Hess <nicolaihess at gmail.com> wrote:
> 
> You can wrap the subclassing and the \removeFromSystem with
> SystemAnnouncer uniqueInstance  suspendAllWhile: [ ]
> 
> 2015-10-24 20:43 GMT+02:00 Peter Uhnák <i.uhnak at gmail.com>:
>> Hi,
>> 
>> is it possible to do fast, non-system wide class subclassing in tests?
>> 
>> Currently I would do something like
>> 
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> MyTest>>testSomething
>>     cls := SomeParent subclass: #Something.
>>     "... do some tests ..."
>>     cls removeFromSystem
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> 
>> This is for example what ClassTest is doing.
>> 
>> However this is very slow, and even for small tests suite --- just ten (so far) test methods it takes over ten seconds to test it all, which is quite bad for TDD.
>> 
>> My guess is that since it has to write to class to the environment and disk and then remove it it takes a while:
>> 
>> ~~~~~~~~~~~~~
>> [ Object subclass: #Something ] timeToRun. "0:00:00:00.021"
>> [ #Something asClass removeFromSystem ] timeToRun. "0:00:00:00.526"
>> ~~~~~~~~~~~~~
>> 
>> is it possible to speed it up? Create classes that are fast to remove?
>> 
>> Thanks,
>> Peter
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20151024/7aa11dd0/attachment.html>


More information about the Pharo-users mailing list