Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: Testing the functionality of sub classes Date: Sun, 20 Aug 2017 01:36:17 +0200 Organization: Decebal Computing Lines: 37 Message-ID: <87lgmff7v2.fsf@munus.decebal.nl> References: <87fucnh2wu.fsf@munus.decebal.nl> <87y3qffim5.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="a3233d099e71e24d901953f13bac9801"; logging-data="18393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SV1Eu7JK0SZLL+4dD+un5ZbSKotrrLoQ=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:WxKtRpdJtT1U3aCFM4BPlDVURqk= sha1:G4oWumsvGXXoGr6sQZJ3lixruuY= Xref: csiph.com comp.lang.java.programmer:37304 v_borchert@despammed.com (Volker Borchert) writes: > Cecil Westerhof wrote: > >> >>I have a class that is extended in several sub classes. Is there a way >> >>to let the tests for the super class to be run on all sub classes? >> > >> >> For the test of the super class AbstractSQL, I have written a test >> class SQLTest in which I implemented all the tests with the sub class >> SQLite3. But there will be more. At the moment there are only two sub >> classes (the other is SQLH2) and for two classes it is not to much >> work. But I expect it to become a little more. So I would like to >> write the test class so that all the tests are done for all the sub >> classes. > > Are you talking JUnit? Then have an abstract class annotated as Yes. I should have added that. > @RunWith(Suite.class) and @Suite.SuiteClasses({ for all your concrete test classes> }) , containing most @Test > methods and declaring a single abstract method that provides > the concrete implementation object to test. For each concrete > class-to-test, you'll need a concrete test class deriving from > the above, listed in its @Suite.SuiteClasses, and implementing > the single abstract method. This derived test class may contain > additional @Test methods applicable to only this concrete > class-to-test. Looks doable. I look into it. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof