使用unity做C语言自动测试.docxVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
root@ubuntu:~/TDD/proj# tree 一 src |-- demo.c 一 demo?h 一 test -- demo_test_group1?c -- demo_test_groupl?out -- demo_test_groupl_Runner.c --demo_test_group2?c ■- demo_test_group2.out 一 demo_test_group2_Runner.c —makefile 、一 unity p「oj为工程(相当于模块) src为产品代码demo.c为源文件,demo.h为头文件 test为测试代码,里面包含了 unity的源码 编译: 在test下meke,将产品代码+测试代码+unity 一起编译 编出两个.out可以直接运行(若一个group则只一个.out) 注: demo_test_group 1 /2_Runner.c 是口 动生成的运行容器 实际工程中的代码结构可设计为: moudule -inc ??tcst模块的测试代码,依赖模块代码和unity框架代码(即include这两个.h) unity作为一个模块,另外编译 (可以当做交换驱动一样的东西,单独编译,然后提供.h即提供api给上层调用) 2、操作步骤 (1)将p呵文件夹放到/root/TDD文件夹下 [root@localhost TDD]# pwd /root/TDD [root@localhost TDD]# tree ■ I-- ThrowTheSwitch-Unity-8661f3f?tar?gz 、——proj | 一 src | | ——demo ? c I 一 demo?h 、——test I-- demo_tesc_group1? c | -- denio_test_group2 ? c 、一makefile 3 directories, 6 files [root@localhost TDD]# | (2)将unity源码解压,复制到test/unity处 [root@localhost TDD]# rav ThrowTheSwitch-Unity-8661f3f proj/test/unity (3)使用自动生成脚本生成测试容器(Runner) 进入 /root/TDD/proj/test/运行命令(注:若无 ruby 则用 apt-get install ruby 安装) ruby unity/auto/generate_test_runner.rb demo_test_group l.c ruby unity/auto/generate_test_runner.rb demo_test_group2.c 会自动根据相应.c生成两个*_Runner.c文件 总计24[roocQlocalhost test]# ruby 总计24 root root 388 09-13 root. root 1016 09-13 root root 465 09-13 root root 1020 root root 1347 09-13 root root 4096 09-07 -rwxr-xr-x drwxruxr-x [root0localhost test]#110111 -rwxr-xr-x drwxruxr-x [root0localhost test]# 1 10 1 1 1 10:39 demo_test_groupl_Runner?c 10:14 deino_test_group2 ? c 10:40 demo test group2 Runner.c 10:10 inakef ile 07:20 unity (4)编译运行 编译: make即可 会编出两个.out 运行: ./demo_test_group l.out ./demo_test_group2.out 也可以将运行命令写入到makefile中,编译测试一步完成 如在最后加./$(TARGET1) default: # ruby auto/generate_test_runner?rb test/TestProductionCode?c test/no_ruby/ TestProductionCode_Runner?c e$(C_COMPILER) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -O $(TARGET1) ^(C^COMPILER) $(INC2DIRS) $(SYMBOLS) $(SRC【F1LES2) -o $(TARGET2) ./$(TARGET1) ./$(TARGET2) 结果: rootKubuntu:*/TDD/proj/test# make

文档评论(0)

ggkkppp + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档