-1
我有一个groovy脚本调用webservice.I想检查webservice调用是否成功使用Junit测试用例运行groovy脚本。请帮助如何编写junit测试用例来运行groovy脚本并检查它是否返回值
我有一个groovy脚本调用webservice.I想检查webservice调用是否成功使用Junit测试用例运行groovy脚本。请帮助如何编写junit测试用例来运行groovy脚本并检查它是否返回值
您将需要嵌入Groovy解释在您的测试代码:
// call groovy expressions from Java code
Binding binding = new Binding();
binding.setVariable("foo", new Integer(2));
GroovyShell shell = new GroovyShell(binding);
Object value = shell.evaluate("println 'Hello World!'; x = 123; return foo * 10");
assert value.equals(new Integer(20));
assert binding.getVariable("x").equals(new Integer(123));
进口groovy.lang.GroovyClassLoader; import groovy.lang.GroovyObject; import java.io.File; 公共类测试{ \t \t \t公共静态无效主要(字符串ARGS [])抛出的Throwable { \t \t \t 父类加载器= Test.class.getClassLoader(); GroovyClassLoader loader = new GroovyClassLoader(parent); GroovyClassLoader(parent); GroovyClassLoader(parent); GroovyClassLoader \t class groovyClass = loader.parseClass(new File(“src/main/resources/scripts/test.groovy”)); \t //让我们在实例上调用某种方法 \t GroovyObject groovyObject =(GroovyObject)groovyClass.newInstance(); \t Object [] arg = {“cvgf”,“xxx”}; \t groovyObject.invokeMethod(“run”,arg); \t} } –
我得到以下错误: 异常线程 “main” org.codehaus.groovy.control.MultipleCompilationErrorsException:启动失败: 无法解决类的SOAPClient \t高清客户端=新的SOAPClient(URL) ^ –