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;
}
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.
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"
};
5) When I tried to run it using this command:
C:\derby_src\development_branch\trunk>java
org.apache.derbyTesting.functionTests.harness.RunSuite derbylang
The _Script test failed, predictably since my test was not an SQL test, with
this output in the derbylang_diff.txt file:
********* Diff file derbylang/derbylang/_Suite.diff
*** Start: _Suite jdk1.4.2_09 derbylang:derbylang 2006-08-30 15:14:30 ***
0 add
> ...F.....
> There was 1 failure:
> 1)
> MathTrigFunctionsTest(org.apache.derbyTesting.functionTests.tests.lang.LangScripts)junit.framework.AssertionFailedError:
> SQL script missing:
> org/apache/derbyTesting/functionTests/tests/lang/MathTrigFunctionsTest.sql
> FAILURES!!!
> Tests run: 8, Failures: 1, Errors: 0
Test Failed.
*** 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?
Thanks,
Susan
----- Original Message ----
From: Daniel John Debrunner [EMAIL PROTECTED]
[snip]
> The following page has been changed by SusanCline:
> http://wiki.apache.org/db-derby/IntroToJUnit
This is good stuff Susan, Thanks.
The section on "JUnit tests and the Derby test harness" says the
information is valid as of 8/29 but it's actually out of date by a few
days. :-) Fast moving target. BaseJDBCTestCase now provides utilities
for a single connection, so a conn field is not needed, and the JUnit
test should be added to any existing _Suite, not directly to the old
harness suite runall files.
[snip]
Thanks,
Dan.