Bug 19633 JUnit launch configurations are not honoring class path
If I make a junit test that needs different things on the classpath than what a project needs for building, and try to make a launch configuration that reflects that, it looks like the junit runner ignores the LC and just goes with the project build classpath. The concrete example I can give is an EJB, which is built as a generic J2EE component (using sun's j2ee SDK), and I want to test against Weblogic, but don't want to be forced to put weblogic.jar in the the build classpath. If I put the vendor-specific jar (i.e. weblogic.jar) into the build path, the junit test runs fine. If I put it into the launch configuration user classpath, the weblogic InitialContextFactory is not found (instantiated via reflection). If I put it into the bootstrap classpath, the InitialContextFactory is found, but weblogic blows up later on in the test, possibly due being loaded by the bootstrap CL. This problem is repeatable without J2EE app servers involved, and shows up any time a unit test is loading a class via reflection. The trivial case can be worked around by using the boostrap classpath, but the more significant one cannot.
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfiguration.java
if (keepAlive(configuration) && runMode.equals(ILaunchManager.DEBUG_MODE))
			argv.add(0, "-keepalive"); 
			
		for (int i= 0; i < testTypes.length; i++) 
			argv.add(testTypes[i].getFullyQualifiedName());
	
		String[] args= new String[argv.size()];
		argv.copyInto(args);
		vmConfig.setProgramArguments(args);
		return vmConfig;
	}
	
	private String[] createClassPath(IType type) throws CoreException {
		URL url= JUnitPlugin.getDefault().getDescriptor().getInstallURL();
		String[] cp= JavaRuntime.computeDefaultRuntimeClassPath(type.getJavaProject());
		String[] classPath= new String[cp.length + 2];
		System.arraycopy(cp, 0, classPath, 2, cp.length);
		try {
			
			classPath[0]= Platform.asLocalURL(new URL(url, "bin")).getFile(); 
			classPath[1]= Platform.asLocalURL(new URL(url, "junitsupport.jar")).getFile(); 
		} catch (MalformedURLException e) {
			JUnitPlugin.log(e); 
		} catch (IOException e) {
			JUnitPlugin.log(e); 
		}
		return classPath;
	}	
}