ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mariano Benitez <mari...@fuegolabs.com>
Subject Re: can I change junit runner main class
Date Tue, 10 Feb 2004 22:18:37 GMT
another option would be to let people extend CommandLineJava and 
overwrite the method getCommandLine() to change the arguments, so I can 
customize my command line while you maintain the contract of JUnitRunner.

I think I will move in this direction since not only I need to change 
the main class, but also make the classpath an argument of the main 
class and not a java argument, for example:

java -classpath whatever.jar JUnitTestRunner blah

to

java -jar /path/myJar.jar -classpath whatever.jar JUnitTestRunner blah

MAriano

Mariano Benitez wrote:

>
>
>> I assume that your class understands all the command line arguments
>> Ant's testrunner uses and passes them along.  How would your class
>> deal with new arguments we add?
>>  
>>
> My class is just a bootstrap that do some classloading stuff regarding 
> my application and then invokes the main class (JUnitRunner) with the 
> parameteres it received in the first place.
>
>> The main problem with opening up access to the test runner class is
>> just that.  As soon as we do it, we run the risk of breaking other
>> people's builds when we change the protocol between the task and the
>> test runner.  There is no danger now, as we always know the main class
>> that gets invoked.
>>  
>>
> I agree 100% with you on this, it is just that I need to take control 
> "before" the main class is executed, actually I build a classloader 
> where the main class (Runner) is loaded and executed.
>
> I know this is a quite unique situation but I just wanted to expose my 
> case to see if it is so unique that is ok that I handle it myself 
> only. I have patched JUnitTask to specify another main class that I 
> built that ultimately call JUnitRunner as usual.
>
>>> 1) leave <junit forked="true" jvm="launcher"> and have "launcher"
>>> script change the command line
>>>   
>>
>>
>> Ugly but portable accross Ant versions.
>>  
>>
> I have scripts since they always have problems with different OS, etc, 
> that was the first option, but I end up having 3 bash processes 
> wrapping java.
>
>>> 2) patch junit to allow me to put a boot class
>>> 3) extend junit (the problem is that JUnitTask.executeAsForked and
>>> commandline are private, so I should patch the task anyway)
>>>   
>>
> what you can do to support extension of JUnit is to leave a hook to 
> alter the commandline, this way I can do whatever I need directly 
> before invoking the runner. You could just leave a method protected so 
> I can extend it and alter the command line in a custom task.
>
>
> Thanks a lot for the attention,
>
> MAriano
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message