[Opensource] unit testing with Expresso
Gabor Nagypal
nagypal at web.de
Fri Jul 4 01:57:28 PDT 2003
Hi everybody,
I am wondering, how to execute unit test (mainly junit) under expresso.
Browsing the examples, the javadoc, the source and the existing
documentation I have the impression that the following method is
recommended (could you correct me, if I am wrong?):
- Make my junit test cases and test suites.
- Add a public Enumeration getTests() method to my schema which lists
the tests
- Run the tests with the TestController controller.
It sounds good, but I could not manage to do it. When I run the
TestController I get an error message that my tests does not contain any
test cases (which is not the case, they do). Could you please somebody
tell me what I do wrong, and what is the proper way to run junit test
with Expresso?
Here is what I exactly did:
I made two extremely simple test cases just to test the testing system.
First test case:
public class FirstTest extends TestCase {
...
public void testFirstThing() {
logger.info("Here is the testFirstThing()");
Assert.assertTrue(true);
}
The second test case is similar, with a public void testSecondThing()
test. I.e. I have two tests, testFirstThing and testSecondThing, both of
them should pass.
My getTests() method in the schema:
public Enumeration getTests() {
Vector result = new Vector();
/*copy tests of the superclass*/
Enumeration superE = super.getTests();
while (superE.hasMoreElements()) {
result.add(superE.nextElement());
}
/*add our tests*/
result.add(new TestSuite(FirstTest.class,"First"));
result.add(new TestSuite(SecondTest.class,"Second"));
return result.elements();
}
The result (on the log console):
75484 [Thread-8] INFO controller.TestController - Test Started
75484 [Thread-8] INFO controller.TestController - A test failure has
occurred
75484 [Thread-8] INFO controller.TestController -
junit.framework.AssertionFail
edError: No tests found in junit.framework.TestSuite
75484 [Thread-8] INFO controller.TestController - Time: 0
75484 [Thread-8] INFO controller.TestController - FAILURES!!!
75484 [Thread-8] INFO controller.TestController - Test Results:
75484 [Thread-8] INFO controller.TestController - Run: 1 Failures: 1
Errors: 0
75484 [Thread-8] INFO controller.TestController - There was 1 failure:
75484 [Thread-8] INFO controller.TestController - 1)
warning(junit.framework.Te
stSuite$1)
75484 [Thread-8] INFO controller.TestController - "No tests found in
junit.fra
mework.TestSuite"
Regards,
Gabor
More information about the Opensource
mailing list