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 DanDebrunner
Date Thu, 31 Aug 2006 16:43:20 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 DanDebrunner:
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.
  
  [[TableOfContents]]
- 
- == The junit test type ==
- The name of a Derby test is the argument supplied to `org.apache.derbyTesting.functionTests.harness.RunTest`
when the test is run. Derby JUnit test names always end with `.junit`, e.g. `somesuite/SomeTest.junit`.
In other words, the test type is `junit`. The file that implements a test is a java file,
e.g. `SomeTest.java`. The test harness uses the last part of the ''name'' to decide how it
should run the test. If the name ends with `.java`, the harness knows that the test is a java
class with a `main()` method. If the name ends with `.junit`, the harness knows it is a java
class which can be run by a JUnit test runner. No actual file exists with the `.junit` suffix.
  
  == Base JUnit test classes ==
  After some discussion on derby-dev, a set of base classes to be used when writing JUnit
tests were created.
@@ -88, +85 @@

  
  Please do not reference the internal Derby class that define SQL states. This class is not
part of Derby's public interface, and should thus not be used to check for expected SQL states.
  
+ == Running Tests ==
+ 
- == Running tests using Junit directly ==
+ === Running tests using Junit directly ===
  
  Tests can be run using the Junit 3.8 !TestRunners. The classpath needs to include the junit.jar
and the Derby classes.
  
@@ -96, +95 @@

  test may change its behaviour in unpredictable ways.
  One aspect of this is that the junit TestRunners do not automatically start with securityManager,
so you need to add that yourself, using -Djava.security.manager -Djava.security.policy=<policyfile>.
  
- === batch run ===
+ ==== batch run ====
  {{{
  > java -cp '../../tools/java/junit.jar;../../classes' junit.textui.TestRunner
          org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest
@@ -106, +105 @@

  OK (27 tests)
  >
  }}}
- === GUI (awt) run ===
+ ==== GUI (awt) run ====
  {{{
  > java -cp '../../tools/java/junit.jar;../../classes' junit.awtui.TestRunner
  }}}
  The supply the complete name of the test class in the top window, e.g. `org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest`.
+ 
+ === Running tests using the old Derby harness ===
+ 
+ The [:KillDerbyTestHarness:old Derby harness] supports running JUnit tests directly and
from its suite.runall files.
+ The name of a Derby JUnit test is the test name using the suffix `.junit` instead of `.java`,
e.g. `somesuite/SomeTest.junit`. In other words, the test type is `junit`. The file that implements
a test is a java file, e.g. `SomeTest.java`. The test harness uses the last part of the ''name''
to decide how it should run the test. If the name ends with `.java`, the harness knows that
the test is a java class with a `main()` method. If the name ends with `.junit`, the harness
knows it is a java class which can be run by a JUnit test runner. No actual file exists with
the `.junit` suffix.
+ 
+ The harness can be used to run individual JUnit tests or tests that are suites, in both
cases the `RunTest` class is used. `RunSuite` is only
+ for suites defined by the old harness setup (i.e. `.runall` files)
+ {{{
+ # Run the set of language JUnit tests
+ java org.apache.derbyTesting.functionTests.harness.RunTest lang/_Suite.junit
+ 
+ # Run one language JUnit test
+ java org.apache.derbyTesting.functionTests.harness.RunTest lang/GroupByExpressionTest.junit
+ 
+ }}}
+ 
+ <!> JUnit tests run within the old harness can take advantage of the harness's facility
to control the environment and when
+ the test is run by using properties files, exclude etc. However, the practice is strongly
discouraged as it makes it harder
+ to run tests directly using JUnit test runners, which is the eventual goal. Most of the
facilities provided by the old harness
+ now exist in the JUnit utility classes in the `org.apache.derbyTesting.junit` package.
  
  == Switching the Derby harness over to JUnit ==
  

Mime
View raw message