db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Db-derby Wiki] Update of "DerbyJUnitTesting" by KristianWaagan
Date Wed, 03 May 2006 07:44:46 GMT
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 KristianWaagan:
http://wiki.apache.org/db-derby/DerbyJUnitTesting

------------------------------------------------------------------------------
  This page will describe how to run Derby JUnit tests, and how to write new JUnit tests for
Derby. All features of the test harness related to JUnit testing should be described here
as well.
  
  == Base JUnit test classes ==
- After some duscussion on derby-dev, a set of base classes to be used when writing JUnit
tests were created.
+ After some discussion on derby-dev, a set of base classes to be used when writing JUnit
tests were created.
  These are:
   * `BaseTestCase`
   * `BaseJDBCTestCase`
   * `TestConfiguration` 
   * `JDBCClient`
  
- To write a JUnit test that uses JDBC, make your test class extend `BaseJDBCTestCase`. Then
you can add test methods, write your `setUp` and `tearDown` methods and finally the `suite`
method that returns a suite of tests to run (typically all tests in the test class). `BaseJDBCTestCase`
provides a set of often used functionality, for instance the method `getConnection` to obtain
a connection to the default database. If you are missing something, ask on derby-dev or create
a sub-task/link a Jira isse to DERBY-1122.
+ To write a JUnit test that uses JDBC, make your test class extend `BaseJDBCTestCase`. Then
you can add test methods, write your `setUp` and `tearDown` methods and finally the `suite`
method that returns a suite of tests to run (typically all tests in the test class). `BaseJDBCTestCase`
provides a set of often used functionality, for instance the method `getConnection` to obtain
a connection to the default database. If you are missing something, ask on derby-dev or create
a sub-task/link a Jira issue to DERBY-1122.
  
  `BaseTestCase` is to be used for JUnit tests not using the JDBC API.
  
@@ -22, +22 @@

  
  Information about JUnit can be found at http://www.junit.org
  The usage of JUnit in Derby is currently based on JUnit 3.8.1.
+ 
+ === The suite() method ===
+ The `suite()` method is s static method returning the tests to be run. We use it to gain
more flexibility in which test methods are executed and the environment they are executed
in. For instance, the use of the `suite()` method allows us to use test decorators (the most
common case is setting up and populating a common database used by all tests in the suite).
+ 
+ By default, all test methods whose name starts with `test` are added to the suite, typically
with `new TestSuite(MyDerbyTests.class, "My suite name")`. If there are tests that should
only be run in certain scenarioes, logic for doing this should be placed in `suite()`. The
prominent example is a test method that is only to be run in the !DerbyNetClient framework.
To fix this, name the method for instance `clientSomeTest` and add it manually to the suite
if `BaseJDBCTestCase.usingDerbyNetClient()` returns true with `suite.addTest(new MyDerbyTests("clientSomeTest"))`.
In general, all tests should be written to be able to run under any framework, and tests written
for a specific framework should be placed in a separate test class. When it is run should
be controlled by the mechanisms provided by the test harness (exclude/skip files).
  
  == Requested features for the JUnit harness ==
  Features requested for the JUnit harness on derby-dev. Note that this page is intended to
be a summary page only. In general, all information presented here should be found in the
mail archives for derby-dev as well (you can search here: http://www.nabble.com/Derby-f356.html).

Mime
View raw message