db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vemund Ostgaard <Vemund.Ostga...@Sun.COM>
Subject Re: [junit] different configurations at test level Was - Re: [junit] Top-level suites added
Date Fri, 29 Sep 2006 14:44:15 GMT
Daniel John Debrunner wrote:

> Vemund Ostgaard wrote:
>
>> This would mean that when executing a single TestCase class (or 
>> suite) with a junit runner, the default behaviour could be to run 
>> with all (supported) frameworks if that is what is most common. 
>> Running with just a selected framework could be possible with a 
>> system property.
>
<snip>

> B) Have a test's suite method just set up a suite as it sees fit:
>
>       public static Test suite() {
>           TestSuite suite = new TestSuite();
>
>           // Embedded tests
>           suite.add(TimeHandlingTest.class);
>           suite.add("embeddedTestA");
>           suite.add("embeddedTestB");
>           suite.add("embeddedTestC");
>
>           // Client tests
>           TestSuite client = new TestSuite();
>           client.add(TimeHandlingTest.class);
>           client.add("clientTestA");
>
>           suite.add(new NetworkServerTestSetup(client));
>
>           return suite;
>       }
>
> Downsides are:
>     possible lack of consistency, but maybe the consistency is use of 
> the NetworkServerTestSetup decorator.
>     how to handle remote server testing?

The remote server is a special case of the "client" framework here. You 
want the "client" tests to be run, but you don't want the 
NetworkServerTestSetup to actually start a network server (unless 
someone solves the problem of doing this remotely on all platforms). So 
the NetworkServerTestSetup needs to handle this by just doing nothing if 
the server host is set to a remote machine. The tester will have to 
start the server manually before starting the test.

>
> Upside is:
>      clarity
>      matches standard JUnit pattern
>      non-reliance of having the configuration setup at suite setup time.
>
<snip>

> -----------------------------------------------------
>
> Are there any other ideas?  Having written them out, my preference 
> would be B), seems very clear and straight forward. Before I wrote it 
> out I was thinking that none of the solutions were good.

When I made the suggestion you quoted above I was thinking along the 
lines of B, without thinking in detail or having studied the code. I 
think that is the right place to solve the problem, and your code 
suggestion is how I see the default behaviour. In addition it should be 
possible to override with properties, so that the suite does not add the 
"embedded" tests if the user set a property that he did not want 
embedded tests run, only client. For instance, something like:

Testsuite suite = new TestSuite();
if(runEmbedded) {
   Testsuite embedded = new TestSuite();
   suite.add(embedded);
}
if(runClient) {
   Testsuite client = new TestSuite();
   suite.add(new NetworkServerTestSetup(client));
}
// etc.

return suite;
}

Or something along those lines?

Thanks,
Vemund

Mime
View raw message