Hi Sean, For testing you can have two approaches: -You need a mock object, and then you use a Mock library -You want to test something related to classes, and in this case you can use the SUnit extension I introduced a while ago ClassFactoryForTestCase. It's part of the core image.
It supports the creation and the deletion of classes. To ensure keeping the system clean. Noury On 9 déc. 2010, at 17:00, Sean P. DeNigris wrote: > > I was playing with creating temporary classes for testing in a separate > SystemDictionary, so I don't have to worry about removing them. But I'm a > little beyond the boundary of my knowledge (although I stepped through it in > the debugger and it seemed pretty straight forward). Are there any hidden > side-effects/implications of the following? Specifically, after the > SystemDictionary is garbage collected, is the system exactly the same as it > was before the code was run? It seems like a better approach than creating > them in the global namespace and cleaning up. > > testingEnvironment := SystemDictionary withOrganizer: SystemOrganizer new. > > ClassBuilder new > name: #AClassForTesting > inEnvironment: testingEnvironment > subclassOf: Object > type: Object typeOfClass > instanceVariableNames: '' > classVariableNames: '' > poolDictionaries: '' > category: 'TemporaryTesting'. > > newClass := (testingEnvironment at: #AClassForTesting). > newClass > compile: 'greeting > ^ ''hello there''' > classified: 'greeting'. > > newClass new greeting. "Returns 'hello there'" > > Thanks. > Sean > -- > View this message in context: > http://forum.world.st/Creating-temporary-classes-for-testing-tp3080408p3080408.html > Sent from the Pharo Smalltalk mailing list archive at Nabble.com. >
