I've seen this before, and I'm not sure it's a bug.

A testless, non-abstract subclass of a TestCase is useless unless it inherits 
test methods. But if it defines its own test methods, then it isn't clear if it 
was made a subclass to inherit test methods, or if it was made a subclass to 
inherit non-test helper methods, or both. I think to be safe it assumes the 
second.

Implement #shouldInheritSelectors in the superclass to get your intended 
behavior.

> Sent: Saturday, June 03, 2017 at 5:09 PM
> From: "Cyril Ferlicot D." <[email protected]>
> To: Pharo <[email protected]>
> Subject: [Pharo-dev] Abstract test classes are not managed well in SUnit
>
> Hi,
> 
> Today I found a bug in SUnit.
> 
> Sometimes when you have an abstract test class and you override it the
> tests will be inherit or not.
> 
> If a subclass has other tests, the tests will not be inherited. If the
> subclass has no other tests, the tests will be inherited.
> 
> Here is a little script showing the problem:
> 
> TestCase subclass: #A
>       slots: {  }
>       classVariables: {  }
>       category: 'TestProblem'.
>       
> #A asClass subclass: #B
>       slots: {  }
>       classVariables: {  }
>       category: 'TestProblem'.
>       
> #B asClass subclass: #C
>       slots: {  }
>       classVariables: {  }
>       category: 'TestProblem'.
>       
> #A asClass class compile: 'isAbstract
>       ^ self = A'.
>       
> #A asClass compile: 'actualClass
>       ^ self subclassResponsibility'.
>       
> #A asClass compile: 'testTest
>       self actualClass new'.
>       
> #C asClass buildSuiteFromAllSelectors run.
>  "1 run, 0 passes, 0 skipped, 0 expected failures, 0 failures, 1 errors,
> 0 unexpected passes"
> 
> #C asClass compile: 'testAnotherTest
>       self assert: true'.
>       
> #C asClass buildSuiteFromAllSelectors run.
>   "1 run, 1 passes, 0 skipped, 0 expected failures, 0 failures, 0
> errors, 0 unexpected passes"
> 
> 
> In the last line I would expect 2 run cases. 1 pass and 1 error.
> 
> I think this is important to correct because it weaken the strength of
> the tests.
> 
> https://pharo.fogbugz.com/f/cases/20118/SUnit-does-not-manage-well-abstract-test-classes
> 
> 
> -- 
> Cyril Ferlicot
> https://ferlicot.fr
> 
> http://www.synectique.eu
> 2 rue Jacques Prévert 01,
> 59650 Villeneuve d'ascq France
> 
>

Reply via email to