接口测试中遇到的几点问题
来源:互联网 发布:ios 好用的数据库软件 编辑:程序博客网 时间:2024/05/17 07:46
接口测试中用ant运行build.xml时,提示找不到*.properties文件,而在eclipse中运行则是没有问题的。
详情:读取*.config的相应代码如下:
private static URL filePath=Thread.currentThread().getContextClassLoader().getResource("");
private static String fileName = "*.properties";
public ConfigUtil(){}
private static Properties props = new Properties();
static{
try {
props.load(new FileInputStream(filePath.getPath()+File.separator+fileName));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
相应的build.xml代码如下:
<!-- property 定义全局变量-->
<property name="testng.file" value="testng.xml"/>
<property name="src.dir" value="src"/>
<property name="class.dir" value="build/class"/>
<property name="lib.dir" value="build/lib"/>
<property name="report.dir" value="test-output"/>
<property name="report_rar.dir" value="report_rar"/>
<property name="testngoutput.dir" value="test-output"/>
<taskdef resource="testngtasks" classpath="${lib.dir}/testng-6.5.1.jar"/>
<!-- 编译 -->
<target name="compiles" depends="init" description="compile the source files">
<javac srcdir="${src.dir}" destdir="${class.dir}" classpathref="classes" includeantruntime="on">
<compilerarg line="-encoding UTF-8 "/>
<classpath refid="Test-classpath"/>
</javac>
</target>
<!-- 运行测试 -->
<target name="regression" depends="compiles">
<testng outputdir="${testngoutput.dir}" classpathref="classes" delegateCommandSystemProperties="true">
<classpath refid="Test-classpath"/>
<xmlfileset dir="${basedir}" includes="${testng.file}"/>
</testng>
</target>
ant运行时的class路径是:工程路径/build/calss,所以提示:工程路径/build/calss/*.properties文件找不到。
暂时解决方法:在build.xml文件的初始化中添加语句:<copy file=" " todir=" "/>
应该是在eclipse中和用ant运行的classpath不同,导致到不到配置文件,有时间再详细了解一下区别,此文件先暂记于此。
- 接口测试中遇到的几点问题
- Android Fragment使用中遇到的几点问题
- Mybatis中遇到几点问题
- 接口测试注意的几点
- python接口测试中遇到问题
- 关于接口的几点问题
- 记录几点在开发中遇到的问题 2015-7-28 (会更新)
- 最近写shell脚本遇到的几点问题总结
- 网站常遇到的攻击性问题几点防御
- 记录调试接口中遇到的问题
- web接口测试中需要测试的几个点
- 支付宝接口需要特别注意的几点问题
- java中抽象类和接口的几点区别
- 关于JAVA中接口的几点理解
- 关于接口的几点
- HttpClient 接口测试遇到的问题及解决方案
- CTS测试中遇到的线程问题
- 测试授权过程中遇到的问题
- Java Filter过滤机制详解
- 从30岁到35岁:为你的生命多积累一些厚度
- 【javaMail】赵雅智_javaMail(5)准备实验环境
- Linux 下使用find rm命令删除svn目录
- 未能解析引用的程序集
- 接口测试中遇到的几点问题
- 程序员的计划
- 报错:'Could not load NIB in bundle: 'NSBundle解决办法
- <s:action>的用法
- B树、B-树、B+树、B*树
- ocs_lisence加密
- 如何改善软件的用户体验 之 颜色与UI
- poj2106
- 报错:this class is not key value coding-compliant for the key closeLotTextField解决方法