Unit testing Cmockery 简单使用
生活随笔
收集整理的這篇文章主要介紹了
Unit testing Cmockery 简单使用
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
/*********************************************************************** Unit testing Cmockery 簡單使用* 說明:* 之前早有聽說過Cmockery,但一直沒有使用起來,主要是也不知道用來做* 什么,當(dāng)然現(xiàn)在其實(shí)也不知道用來做什么,不過還是想編譯一下,看下效果,* 然后搞了一個(gè)最簡單的測試程序看一下效果。** 2016-5-3 深圳 南山平山村 曾劍鋒*********************************************************************/一、參考文章:C單元測試框架之Cmockeryhttp://c4fun.cn/blog/2014/12/06/cmockery/
二、編譯:1. ./configure2. make3. sudo make install4. sudo ldconfig三、Demo Test:#include <stdarg.h>#include <stddef.h>#include <setjmp.h>#include "cmockery.h" // 注意頭文件所在的位置void testFunction(void **state) {printf("zengjf.\n");}int main(int argc, char *argv[]){const UnitTest tests[] = {unit_test(testFunction),};return run_tests(tests);}四、測試結(jié)果:myzr@myzr:~/c_program$ ./a.outtestFunction: Starting testzengjf.testFunction: Test completed successfully.All 1 tests passedmyzr@myzr:~/c_program$
?
總結(jié)
以上是生活随笔為你收集整理的Unit testing Cmockery 简单使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 苹果iOS10 Beta4怎么样 苹果i
- 下一篇: 通过vsphere client创建虚拟