Mock Runtime.getRuntime()?
问题 Can anyone make any suggestions about how best to use EasyMock to expect a call to Runtime.getRuntime().exec(xxx) ? I could move the call into a method in another class that implements an interface, but would rather not in an ideal world. interface RuntimeWrapper { ProcessWrapper execute(String command) throws IOException; } interface ProcessWrapper { int waitFor() throws InterruptedException; } I was wondering if anyone had any other suggestions? 回答1: Your class shouldn't call Runtime