Hi, In order to set up a suite of tests to be executed client-side, I wish to access a server-side resource in my suite() method. This works fine when I run the test from my browser using ServletTestRunner, but I get a "java.lang.reflect.InvocationTargetException" when I attempt to run from a different jvm, ie with junit.textui.TestRunner. Is it possible to access server-side resources in the suite() method when executed from junit.textui.TestRunner? (Please see below for some sample code.) Btw, I have a similar problem when I attempt to set up server-side fixtures in my suite() method by using a TestSetup wrapper and junit.textui.TestRunner. This works fine from browser ServletTestRunner. I have a sinking suspicion that this may have to do with the issue in this thread http://tinyurl.com/cfj2z (Serializing test case classes), but I'd appreciate any feedback. Thanks in advance, Nick.
Here is the sample code. Some details have been left out for brevity. In this example, I want the test to run differently depending on the environment. Because the system property "servertype" is not defined in the textui JVM environment, I get the Exception. public MyTest(String environment) { super("testSomething "); this.environment = environment; } public static Test suite() throws Exception { ServletTestSuite suite = new ServletTestSuite(); boolean isProd = isProd(); if (isProd) { suite.addTest(new MyTest("PROD01")); } else { suite.addTest(new MyTest("STAGE")); } return suite; } private static boolean isProd() { return (System.getProperty("servertype").equals("prd")); } public void beginSomething(WebRequest theRequest) throws Exception { ... } public void testSomething() { ... } Here is the stack-trace: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25)Caused by: java.lang.NullPointerException at com.adsk.ws.externalservices.evolution.MyTest.isProd(MyTest.java:99) at com.adsk.ws.externalservices.evolution.MyTest.suite(MyTest.java:78) ... 7 more