Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 35491 invoked from network); 13 Mar 2006 10:22:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Mar 2006 10:22:58 -0000 Received: (qmail 94704 invoked by uid 500); 13 Mar 2006 10:22:57 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 94667 invoked by uid 500); 13 Mar 2006 10:22:57 -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 94658 invoked by uid 99); 13 Mar 2006 10:22:57 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Mar 2006 02:22:57 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Mar 2006 02:22:56 -0800 Received: from ajax (localhost.localdomain [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id DD74B6ACAB for ; Mon, 13 Mar 2006 10:22:35 +0000 (GMT) Message-ID: <1006007043.1142245355900.JavaMail.jira@ajax> Date: Mon, 13 Mar 2006 10:22:35 +0000 (GMT) From: "Andreas Korneliussen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-919) improve pattern for setting up junit tests In-Reply-To: <1926405507.1138969503535.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-919?page=comments#action_12370144 ] Andreas Korneliussen commented on DERBY-919: -------------------------------------------- The main idea with this issue was to clean up the exisiting tests which inherit from DerbyJUnitTest, so that they can be run as type .junit. I have done some work in this area, however it is not completed in because of the additional harness in compatibility suite. In general, I think junit can be used to write real unit tests as well, not only JDBC-tests. I.e I would like to write some tests that tests store functionality using Junit. In such cases, I think I would not like to inherit from a class which provides me with utility functions to get a JDBC connection. Therefore, one should be careful of what we call BaseDerbyJuniTest and DerbyJUnitTest. I would propose doing the following with BaseDerbyJunitTest 1. Rename it to BaseJDBCTest 2. Maybe provide a setUp() which sets up a connection in the database, using TestUtil. , then call an abstract method called: createDataModel() populateDatamodel() or a more general abstract method like: doAdditionalSetup() In teardown() call abstract methods like: dropDataModel() and close the connection. (or a more general method like doAdditionalSetup) I think BasicDerbyJunitTest should use TestUtil to get the connection. > improve pattern for setting up junit tests > ------------------------------------------ > > Key: DERBY-919 > URL: http://issues.apache.org/jira/browse/DERBY-919 > Project: Derby > Type: Sub-task > Components: Test > Environment: All > Reporter: Andreas Korneliussen > Attachments: BasicDerbyJUnitTest.html, BasicDerbyJUnitTest.java, BasicDerbyJUnitTestTest.java > > The current junit tests cannot be run directly from the java.ui.textrunner by i.e using: > java junit.textui.TestRunner org.apache.derbyTesting.functionTests.tests.junitTests.lang.BooleanTest > .E > Time: 0.008 > There was 1 error: > 1) testBoolean(org.apache.derbyTesting.functionTests.tests.junitTests.lang.BooleanTest)java.lang.NullPointerException > at org.apache.derbyTesting.functionTests.util.DerbyJUnitTest.faultInDriver(DerbyJUnitTest.java:317) > at org.apache.derbyTesting.functionTests.util.DerbyJUnitTest.getConnection(DerbyJUnitTest.java:345) > at org.apache.derbyTesting.functionTests.util.DerbyJUnitTest.getConnection(DerbyJUnitTest.java:335) > at org.apache.derbyTesting.functionTests.tests.junitTests.lang.BooleanTest.testBoolean(BooleanTest.java:136) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > FAILURES!!! > Tests run: 1, Failures: 0, Errors: 1 > The reason is that the tests needs to have some fixture being set up before the test can run, and that this is currently supported by calling a bunch of static methods in the correct order to initialize some static members of DerbyJUnitTest. > The proposed alternative is that the added fixture is set up in the suite() method, which is used by JUnit to get the Test object to be run. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira