Hi Nicholas,

In article <[EMAIL PROTECTED]>,
Mon, 6 Mar 2006 11:29:01 -0800,
"Nicholas Dierauf" <[EMAIL PROTECTED]> wrote: 
nicholas> In order to set up a suite of tests to be executed client-side, I wish
nicholas> to access a server-side resource in my suite() method. This works fine
nicholas> when I run the test from my browser using ServletTestRunner, but I 
get a
nicholas> "java.lang.reflect.InvocationTargetException" when I attempt to run 
from
nicholas> a different jvm, ie with junit.textui.TestRunner. 
nicholas>  
nicholas> Is it possible to access server-side resources in the suite() method
nicholas> when executed from junit.textui.TestRunner?  (Please see below for 
some
nicholas> sample code.)

It may be possible, but I dont't recommend that way.
At least, you have to implement such mechanism by yourself.
Also, you have to take care for the server-side instantiation
which will be done without using suite() method.


nicholas> Here is the sample code. Some details have been left out for brevity. 
In
nicholas> this example, I want the test to run differently depending on the
nicholas> environment. Because the system property "servertype" is not defined 
in
nicholas> the textui JVM environment, I get the Exception.

You might pass the system property as a command-line argument of the JVM,
i.e. java -Dservertype=XXX junit.textui.TestRunner <class-name>.


nicholas> public MyTest(String environment) {
nicholas>   super("testSomething ");
nicholas>   this.environment = environment;
nicholas> }

Is this test really works with ServletTestRunner?
Have you ever test the value of this.environment in testSometing() method?

I think, the MyTest will be constructed with argument value of
"testSomething" for the second instantiateion in the servier-side.
So, this.environment above will have value of "testSomething"
that you are not expecting. I may misunderstanding something, though.


Hope this helps.
----
Kazuhito SUGURI

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to