ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Shadel <shade...@mtc.byu.edu>
Subject Re: How to set a property from a custom task? (LONG)
Date Thu, 20 Sep 2001 20:23:18 GMT
I couldn't say for sure, but check out

and read the section containing this:

==========================

To create a suite of two test cases and run them together, execute: 
TestSuite suite= new TestSuite();
suite.addTest(new MoneyTest("testMoneyEquals"));
suite.addTest(new MoneyTest("testSimpleAdd"));
TestResult result= new TestResult();
suite.run(result);
Another way is to let JUnit extract a suite from a TestCase. To do so you pass the class of
your TestCase to the 
TestSuite constructor. 
TestSuite suite= new TestSuite(MoneyTest.class); 
TestResult result= new TestResult(); 
suite.run(result); 

Use the manual way when you want a suite to only contain a subset of the test cases. Otherwise
the automatic suite extraction is the preferred way. It avoids you having to update the suite
creation code when you add a new test case. 

TestSuites don't only have to contain TestCases. They contain any object that implements the
Test interface. For example, you can create a TestSuite in your code and I can create one
in mine, and we can run them together by creating a TestSuite that contains both: 

TestSuite suite= new TestSuite();
suite.addTest(Kent.suite());
suite.addTest(Erich.suite());
TestResult result= new TestResult();
suite.run(result);

======================

I'm pretty sure you could wrap your test case classes using the TestSetup class described
in the first URL, and where it said "...add your tests and suites here... ", you could use
the methods above (e.g. TestSuite suite= new TestSuite(MoneyTest.class);) to allow Java Reflection
to figure out which tests to run.

Tim

>>> Paul Michali <pcm@cisco.com> 09/20/01 01:46PM >>>


Timothy Shadel wrote:
> 
> For JUnit setup for several test cases check out
> 
> http://junit.sourceforge.net/doc/faq/faq.htm#How%20do%20I%20run%20setup%20code%20only%20once

> 

Will that work, given that I'm running JUnit from Ant and letting JUnit
find all my test cases
via Reflection? If not, is there a way to do this?


PCM (Paul Michali)

Carrier Voice Gateway Business Unit (CVGBU)
Cisco Systems, Inc.
250 Apollo Drive
Chelmsford, MA 01824

Phone : (800) 572-6771 x 45817  (978) 244-5817 [direct]
Paging: (800) 365-4578 [voice]  pcm@epage.cisco.com [email page]


Mime
View raw message