I'm not sure if this is a very high priority for the release, but it is
for me. It seems that the CampSmalltalk standard SUnit TestRunner and Jeff Odell's super-cool test runner (both shipping in-image in D5) don't behave the same when dealing with TestResources. The attached test case package illustrates this difference. While the CS browser properly initializes and resets resources, the other one doesn't. The only fix required is in this method: !SUnitBrowserModel methodsFor! runTests: aCollectionOfTestCasesOrTestSuites | allTestCases resources | allTestCases := OrderedCollection new. aCollectionOfTestCasesOrTestSuites do: [:eachTest | allTestCases addAll: eachTest allTests]. resources := allTestCases inject: OrderedCollection new into: [ :coll :each | coll addAll: each resources. coll]. resources do: [ :res | res isAvailable ifFalse: [ ^TestResult signalErrorWith: 'Resource ', res name, ' could not be initialized']]. self testResult removeAll: allTestCases. self signalResetResults: allTestCases. [aCollectionOfTestCasesOrTestSuites do: [:eachTest | eachTest isTestSuite ifFalse: [self runTest: eachTest] ifTrue: [ eachTest allTests do: [:each | self runTest: each; signalUpdateTestCaseStatus: eachTest withResult: nil]]]] sunitEnsure: [resources do: [:each | each reset]]. ! ! !SUnitBrowserModel categoriesFor: #runTests:!actions!public! ! Of course, Jeff, if you init all your resources by hand, you might want to wrap the code I added in a boolean conditional which could be set as a class (inst) var in SUnitBrowserModel. That's all it would need. Please note: the added code is also the new behavior for TestResource initialization. If a resource fails, at least you now know which one it was ;-) Cheers -- Joseph Pelrine [ | ] MetaProg GmbH Email: [hidden email] Web: http://www.metaprog.com "Inheritance was invented at 2 AM between January 5th and 6th, 1967" - Krysten Nygaard SUnitResourceInitializerTest.pac (2K) Download Attachment |
I think this is another of those those "how you use it" problems - I
initialize my resources "by hand", where Joseph likes his test cases to make sure the resources are available all by themselves. His approach is at least as valid, and probably better, than mine. I noticed the the Test Resource Browser has a bad menu on it also. I'll try to roll out another release candidate for the Browser in the next day or two, incorporating a fix by Steve Waring and this code as well. Maybe I can make a Dolphin Option regarding whether the resources initialize themselves automatically or not. Thanks JP - I'm guessing this problem exists on the VA version too? jlo Joseph Pelrine wrote: > I'm not sure if this is a very high priority for the release, but it is > for me. It seems that the CampSmalltalk standard SUnit TestRunner and > Jeff Odell's super-cool test runner (both shipping in-image in D5) don't > behave the same when dealing with TestResources. The attached test case > package illustrates this difference. While the CS browser properly > initializes and resets resources, the other one doesn't. > > The only fix required is in this method: > > !SUnitBrowserModel methodsFor! > > runTests: aCollectionOfTestCasesOrTestSuites > | allTestCases resources | > > allTestCases := OrderedCollection new. > aCollectionOfTestCasesOrTestSuites do: [:eachTest | allTestCases > addAll: eachTest allTests]. > > resources := allTestCases inject: OrderedCollection new > into: [ :coll :each | coll addAll: each resources. coll]. > > resources do: [ :res | > res isAvailable ifFalse: [ > ^TestResult signalErrorWith: 'Resource ', res name, ' could not be > initialized']]. > > self testResult removeAll: allTestCases. > self signalResetResults: allTestCases. > > [aCollectionOfTestCasesOrTestSuites do: [:eachTest | > eachTest isTestSuite > ifFalse: [self runTest: eachTest] > ifTrue: [ > eachTest allTests do: [:each | > self > runTest: each; > signalUpdateTestCaseStatus: eachTest > withResult: nil]]]] > sunitEnsure: [resources do: [:each | each reset]]. > ! ! > !SUnitBrowserModel categoriesFor: #runTests:!actions!public! ! > > Of course, Jeff, if you init all your resources by hand, you might want > to wrap the code I added in a boolean conditional which could be set as > a class (inst) var in SUnitBrowserModel. That's all it would need. > > Please note: the added code is also the new behavior for TestResource > initialization. If a resource fails, at least you now know which one it > was ;-) > > Cheers > -- > Joseph Pelrine [ | ] > MetaProg GmbH > Email: [hidden email] > Web: http://www.metaprog.com > > "Inheritance was invented at 2 AM between January 5th and 6th, 1967" - > Krysten Nygaard > |
Jeffrey Odell wrote:
> I think this is another of those those "how you use it" problems - I > initialize my resources "by hand", where Joseph likes his test cases to > make sure the resources are available all by themselves. His approach > is at least as valid, and probably better, than mine. Valid, yes. Better - I wouldn't dare say so. But different - yes. The problem is just that the two test runners don't act the same on this test case (and on the 150+ other I have that broke on this when I brought them over from VW) :-( > > > I noticed the the Test Resource Browser has a bad menu on it also. I'll > try to roll out another release candidate for the Browser in the next > day or two, incorporating a fix by Steve Waring and this code as well. > Maybe I can make a Dolphin Option regarding whether the resources > initialize themselves automatically or not. That would be great, Jeff! I'd really like to use your browser, and I'd really like for the differing styles to co-exist. Now all we have to do is argue about which setting will be the default <big grin here>. > Thanks JP - I'm guessing this problem exists on the VA version too? Don't know. Since I've started doing Dolphin, I don't do much on other dialects anymore - not if I don't have to ;-) Apropos VA - since you write clean code, I presume that the problem, as well as the suggested fix, are the same. Joseph Pelrine [ | ] MetaProg GmbH Email: [hidden email] Web: http://www.metaprog.com "Inheritance was invented at 2 AM between January 5th and 6th, 1967" - Krysten Nygaard |
Free forum by Nabble | Edit this page |