软件测试实验学习笔记系列3--单元测试

发表于:2013-8-06 11:03

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:xiajian2010    来源:51Testing软件测试网采编

分享:

  ant脚本运行

  1.首先cd 到相应的java project的目录下 cd java project/testSoftware

  2. 输入ant 或者ant -f build.xml

  3 参看结果:

Buildfile: /home/xiajian/project file/java project/testSoftware/build.xml
clean:
[delete] Deleting directory /home/xiajian/project file/java project/testSoftware/report
compile:
test:
[mkdir] Created dir: /home/xiajian/project file/java project/testSoftware/report/html
[junit] Running demo2.TestSuite
[junit] Testsuite: demo2.TestSuite
[junit] Tests run: 10, Failures: 0, Errors: 0, Time elapsed: 0.097 sec
[junit] Tests run: 10, Failures: 0, Errors: 0, Time elapsed: 0.097 sec
[junit]
[junit] Testcase: testType[0] took 0.002 sec
[junit] Testcase: testType[1] took 0 sec
[junit] Testcase: testType[2] took 0 sec
[junit] Testcase: testType[3] took 0 sec
[junit] Testcase: testType[4] took 0 sec
[junit] Testcase: testType[5] took 0 sec
[junit] Testcase: testType[6] took 0 sec
[junit] Testcase: testType[7] took 0 sec
[junit] Testcase: testType[8] took 0.001 sec
[junit] Testcase: testType took 0 sec
[junitreport] Processing /home/xiajian/project file/java project/testSoftware/report/TESTS-TestSuites.xml to /tmp/null2022323935
[junitreport] Loading stylesheet jar:file:/usr/share/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] Transform time: 564ms
[junitreport] Deleting: /tmp/null2022323935
report:
[echo] Hello world
BUILD SUCCESSFUL

  ant脚本在当前项目下生成了一个report文件夹,其中有相应的测试用例执行的报告

  备注:关于这里的JUnit的实例的代码,我放到了在百度网盘上创建了一个公共链接,有兴趣的可以研究一下,这实例位于testSoftware/src/demo2的中.网盘连接:http://pan.baidu.com/share/link?shareid=1294418402&uk=556148328

  在导入项目时可能出现的问题:

  原先我是在OpenJDK 7的环境下编写这个测试程序的,后来从Ubuntu12.10换到Ubuntu12.04LTS后,系统安装的JDK 是Open JDK 6,所以导入项目时出现了java.lang.UnsupportedClassVersionError: demo2/ParameterTestTriangle : Unsupported major.minor version 错误,百度了一下找到了问题的原因:是因为使用高版本的JDK编译的Java class文件试图在较低版本的JVM上运行. 解决方法:

  一定要清理干净已经生成的文件

  替换成正确的JDK--修JDK的jre以及相的编译器(修改的方法是右击项目属性build path和build compiler中修改)

  修改JRE:

  修改编译器:

  参考资料:

  [1]软件测试实验指导教程/蔡建平, 清华大学出版社, 2009.11
  [2] JUnit实战(第二版)/Peter Tahchiev等著,王魁译, 人民邮电出版社,2012.4
  [3]软件测试v模型的图片来源:http://leochael.blog.163.com/blog/static/1309571200741181733167/
  [4]出现的java错误:http://zhidao.baidu.com/question/455404569.html

相关文章:

软件测试实验学习笔记系列2 -- lint,splint的使用

软件测试实验学习笔记系列4--CppUnit

55/5<12345
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号