Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 11537 invoked from network); 31 Aug 2006 00:57:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 31 Aug 2006 00:57:30 -0000 Received: (qmail 31414 invoked by uid 500); 31 Aug 2006 00:57:29 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 31371 invoked by uid 500); 31 Aug 2006 00:57:29 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 31361 invoked by uid 99); 31 Aug 2006 00:57:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2006 17:57:29 -0700 X-ASF-Spam-Status: No, hits=2.1 required=10.0 tests=DNS_FROM_RFC_WHOIS,RCVD_IN_SORBS_WEB X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [68.142.199.117] (HELO web81301.mail.mud.yahoo.com) (68.142.199.117) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 30 Aug 2006 17:57:28 -0700 Received: (qmail 2073 invoked by uid 60001); 31 Aug 2006 00:57:03 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=pacbell.net; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=sTQZz44fAKM9PfEdhEZW2ERfEKwel2l16ysV90OsIPQU40TPI7TykmYaYj6+RPYNC9dOLwW1DSLE3fGJ0K1kohsrcl3nprN4Zk/CfrfySIAEQ/7xjKiMBwOwwjDKtU4QTaxpsdFJCBSlZVmFPZzIFm5UR5B+ozwxNFqRFMRc4h0= ; Message-ID: <20060831005703.2071.qmail@web81301.mail.mud.yahoo.com> Received: from [32.97.110.142] by web81301.mail.mud.yahoo.com via HTTP; Wed, 30 Aug 2006 17:57:03 PDT Date: Wed, 30 Aug 2006 17:57:03 -0700 (PDT) From: Susan Cline Subject: Re: Integrating a JUnit test into the test harness was: Re: [Db-derby Wiki] Update of "IntroToJUnit" by SusanCline To: derby-dev@db.apache.org In-Reply-To: <44F61AA2.5060505@apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --- Daniel John Debrunner wrote: > home4slc@pacbell.net wrote: > > > As Dan mentioned below my example about integrating a JUnit test into the Derby test harness > > was not accurate. I've changed the wiki page IntroToJUnit to point to the other JUnit wiki > > pages which are more relevant to Derby for information about this. > > > > However, I've spent some time trying to get my JUnit test that runs fine in stand-alone mode > > to be integrated into the test harness. > > > > To be clear what I mean about stand-alone mode, I am successful with these two invocations > > of the MathTrigFunctionsTest JUnit class: > > > > C:\derby_src\development_branch\trunk>java junit.textui.TestRunner org.apache.de > > rbyTesting.functionTests.tests.lang.MathTrigFunctionsTest > > ................ > > Time: 21.231 > > OK (16 tests) > > > > C:\derby_src\development_branch\trunk>java org.apache.derbyTesting.functionTests > > .harness.RunTest lang/MathTrigFunctionsTest.junit > > *** Start: MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 14:24:08 *** > > *** End: MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 14:24:48 *** > > > > I'm not sure if I have enough time to get this working, or if someone else can help. Here's > what I've > > done so far, maybe someone has an idea of what needs to be done to get this to work. > > > > 1) Created a class that extends the BaseJDBCTestCase class, which is in the > > org.apache.derbyTesting.functionTests.tests.lang package. > > (I've removed the private Connection variable per Dan's suggestion below.) > > > > 2) I created a suite() method shown below: > > > > public static Test suite() { > > TestSuite suite = new TestSuite(); > > suite.addTestSuite(MathTrigFunctionsTest.class); > > TestSetup wrapper = new BaseJDBCTestSetup(suite) { > > public void setUp() throws Exception { > > // initialize variables > > } > > protected void tearDown() throws Exception { > > super.tearDown(); > > } > > }; > > return wrapper; > > } > > You don't need to have the wrapper, I think what you have defined there > is a new decorator class that does nothing. > > BaseJDBCTestSetup is an abstract TestSetup class or decorator that can > be used to build a concrete decorator that uses a JDBC connection. > Decorators are used to wrap logic (setUp and tearDown) around a set or > suite of tests. For example if all the cases (fixtures) in your test > case used a fixed schema that could be created once, you would create it > in a test decorator setUp and remove it in the tearDown, something like > > > TestSetup wrapper = new BaseJDBCTestSetup(suite) { > > public void setUp() throws Exception { > > Statement s = getConnection().createStatement(); > s.execute("CREATE TABLE ..."); > s.execute("CREATE INDEX ..."); > ... > s.close(); > > } > > protected void tearDown() throws Exception { > > Statement s = getConnection().createStatement(); > s.execute("DROPTABLE ..."); > ... > s.close(); > > super.tearDown(); > > } > > }; Oh, okay, thanks I did not know that. I removed the wrapper and just have a separate setup() and suite() method. > > > > 3) I looked at the _Suite.java file in the lang package. From what I can tell this adds the > > suites from LangScripts class' suite. > > It is meant to run all JUnit tests in the lang package, the LangScripts > is one such test, others have yet to be added because they might need > additional functionality. > > > > > 4) Looking at the LangScripts class it runs only SQL tests. Just for kicks I added my JUnit > > test class name to the LangScripts tests to be run to see what would happen; > > > > private static final String[] SQL_LANGUAGE_TESTS = { > > "case", > > "constantExpression", > > "MathTrigFunctionsTest" > > }; > > LangScripts is a Junit test class that runs SQL scripts in the lang > package, the array of names in SQL_LANGUAGE_TESTS are names of .sql > files. It's not a general holder for langauge JUnit tests. > > > > *** End: _Suite jdk1.4.2_09 derbylang:derbylang 2006-08-30 15:14:57 *** > > > > Does anyone know what I have to do to get my MathTrigFunctionsTest to run as part of the > > test harness using the _Suite class? > > Add a line like this to the tests.lang._Suite.suite() method > > suite.addTest(MathTrigFunctionsTest.suite()); I wondered about that, but thought that maybe the goal was to make it more modular, and not just add individual tests this way. So now I've done that and removed the entry from LangScripts and here is the results of running the tests; No failures when running my test by itself: java org.apache.derbyTesting.functionTests.harness.RunTest lang/MathTrigFunctionsTest.junit *** Start: MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 17:48:42 *** *** End: MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 17:49:11 *** No failures when running the _Suite by itself: java org.apache.derbyTesting.functionTests.harness.RunTest lang/_Suite.junit *** Start: _Suite jdk1.4.2_09 2006-08-30 17:49:45 *** *** End: _Suite jdk1.4.2_09 2006-08-30 17:50:27 *** But when I try to run the entire derbylang suite the only test that fails is _Suite, but I'm wondering if it really failed: java org.apache.derbyTesting.functionTests.harness.RunSuite derbylang derbylang_fail.txt: derbylang/derbylang.fail:lang/_Suite.junit But derbylang_pass.txt shows this at the bottom of the output: ... derbylang/derbylang.pass:lang/_Suite.junit /MathTrigFunctionsTest.pass:lang/MathTrigFunctionsTest.junit Is there something else I need to do to make sure that RunSuite derbylang reports that _Suite passes? > > Thanks for trying this stuff out, it shows where I need to add more > comments etc. Sure, you're welcome. > Dan. > >