我在groovy的concateneate不工作

时间:2015-07-21 20:25:38

标签: testing groovy tdd soapui

我有一个问题,我如何能够将我的方式与文件连接起来

import java.util.Properties
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def path = groovyUtils.projectPath

Properties properties = new Properties();
File propertiesFile = (path + JsonConfig.properties);
log.info propertiesFile
propertiesFile.withInputStream {
   stream -> properties.load(stream);
}

iterator = properties.keySet().iterator();

while(iterator.hasNext()) {
       key = iterator.next();
       value = properties[key];

       testRunner.testCase.testSuite.project.setPropertyValue(key, value);
}

错误:

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'E:\JsonConfig.properties' with class 'java.lang.String' to class 'java.io.File' error at line: 9

1 个答案:

答案 0 :(得分:0)

path + JsonConfig.properties似乎是String。您可能想要调用File构造函数。替换:

File propertiesFile = (path + JsonConfig.properties);

使用:

File propertiesFile = new File(path + JsonConfig.properties);