From derby-commits-return-7949-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Thu Jul 05 15:25:25 2007 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 82084 invoked from network); 5 Jul 2007 15:25:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jul 2007 15:25:25 -0000 Received: (qmail 83153 invoked by uid 500); 5 Jul 2007 15:25:27 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 83122 invoked by uid 500); 5 Jul 2007 15:25:27 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 83107 invoked by uid 99); 5 Jul 2007 15:25:27 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2007 08:25:27 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2007 08:25:24 -0700 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id DBD7759A07 for ; Thu, 5 Jul 2007 15:25:03 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki To: derby-commits@db.apache.org Date: Thu, 05 Jul 2007 15:25:03 -0000 Message-ID: <20070705152503.19818.73631@eos.apache.org> Subject: [Db-derby Wiki] Update of "ConvertOldTestToJunitTips" by KatheyMarsden X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Db-derby Wiki" for change notification. The following page has been changed by KatheyMarsden: http://wiki.apache.org/db-derby/ConvertOldTestToJunitTips ------------------------------------------------------------------------------ * run {{{derbyall}}} - check for no (new) failures * {{{svn diff}}} to create a patch & attach to the jira issue along with the output of {{{svn stat}}} + === Common mistakes === + * Not using the utility methods that have already been created. + There are quite a few built in utility methods which can be used in tests. Before you get started, study the [http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/package-summary.html derbyTesting.junit javadoc] for utility methods and decorators that are already available. Tests using JDBC should inherit from [http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.html BaseJDBCTestCase] and can use all of the utility methods available in that class such as getConnection, openDefaultConnection, createStatement, assertSQLState, usingDerbyNetClient etc. Some of the common methods used in [http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/JDBC.html JDBC] are assertFullResultSet for checking result sets returned, and the vmSupportsXXX() calls for jvm specific behavior. + * Misusing the utility methods. + Be careful of the order of the arguments of the utility methods. For example in [http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.html#assertSQLState(java.lang.String,%20java.lang.String,%20java.sql.SQLException) assertSQLState] the expected exception comes first. Even though the test might pass if the arguments are reversed, if it were to ever fail the message would not make sense. + * Not using the utility methods to get a connection. + Normally to get a connection to the default database, you should use [http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.html#getConnection() getConnection()] This is a single connection that is reused so if you call getConnection twice, you will get the same connection. If you want a secondary connection, use [http://db.apache.org/derby/javadoc/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.html#openDefaultConnection() openDefaultConnection] + * Not removing the old test files. + You should remove the old test files, canons and remove the old test from its suite. ant clobbber before you build, to make sure their are no residual dependencies on the old test files. + + + + + == When writing tests is there a short cut to creating the ResultSet two dimensional arrays? == You can use org.apache.derbyTesting.junit.Utilities.showResultSet(ResultSet rs) to print out the two dimensional array and then cut and paste into your code.