<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《C单元测试之Mock Test篇》的评论</title>
	<atom:link href="http://tonybai.com/2008/04/12/mock-test-in-c-unit-test/feed/" rel="self" type="application/rss+xml" />
	<link>https://tonybai.com/2008/04/12/mock-test-in-c-unit-test/</link>
	<description>一个程序员的心路历程</description>
	<lastBuildDate>Fri, 17 Apr 2026 15:31:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>作者：guixue</title>
		<link>https://tonybai.com/2008/04/12/mock-test-in-c-unit-test/#comment-307</link>
		<dc:creator>guixue</dc:creator>
		<pubDate>Wed, 12 Aug 2009 20:33:30 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/2008/04/12/c%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95%e4%b9%8bmock-test%e7%af%87/#comment-307</guid>
		<description>挺不错的！
之前看了一下 cmockery 的mock有点不是太理解，现在明白了，用它实现：
return (void*)mock();和will_return(funName, const_mock_Value)的方式。
这个google开源的c单元测试框架也还是不错的，虽小功能不弱。http://cmockery.googlecode.com/svn/trunk/doc/index.html</description>
		<content:encoded><![CDATA[<p>挺不错的！<br />
之前看了一下 cmockery 的mock有点不是太理解，现在明白了，用它实现：<br />
return (void*)mock();和will_return(funName, const_mock_Value)的方式。<br />
这个google开源的c单元测试框架也还是不错的，虽小功能不弱。http://cmockery.googlecode.com/svn/trunk/doc/index.html</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：gzm55</title>
		<link>https://tonybai.com/2008/04/12/mock-test-in-c-unit-test/#comment-308</link>
		<dc:creator>gzm55</dc:creator>
		<pubDate>Tue, 17 Mar 2009 01:54:47 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/2008/04/12/c%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95%e4%b9%8bmock-test%e7%af%87/#comment-308</guid>
		<description>噢, 谢谢. 我是最近搜关于mock的文章就来到这里, 看了您的几篇日志, 学到不少东西, 呵呵

现在对mock主要的争议是什么呀?</description>
		<content:encoded><![CDATA[<p>噢, 谢谢. 我是最近搜关于mock的文章就来到这里, 看了您的几篇日志, 学到不少东西, 呵呵</p>
<p>现在对mock主要的争议是什么呀?</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：gzm55</title>
		<link>https://tonybai.com/2008/04/12/mock-test-in-c-unit-test/#comment-309</link>
		<dc:creator>gzm55</dc:creator>
		<pubDate>Mon, 16 Mar 2009 11:17:50 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/2008/04/12/c%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95%e4%b9%8bmock-test%e7%af%87/#comment-309</guid>
		<description>我的方法是

/* test.c */
#include mock.h
#define fopen mock_fopen

#include &quot;biz_operation.c&quot;

#undef fopen

如果用 cgreen，可以在 mock_open 中用它的 mock() 宏来选择具体 mock 哪个函数里面的fopen，而其他的使用原始的fopen。直接 include .c 文件另一个好处就是能对 static 函数进行测试。当然这么做的限制也是很大的。

不知 Tony 老师是否试过 CMock 来对付 mock 问题？在对 c 的 mock test 和 static test 还有什么新的方法？</description>
		<content:encoded><![CDATA[<p>我的方法是</p>
<p>/* test.c */<br />
#include mock.h<br />
#define fopen mock_fopen</p>
<p>#include &quot;biz_operation.c&quot;</p>
<p>#undef fopen</p>
<p>如果用 cgreen，可以在 mock_open 中用它的 mock() 宏来选择具体 mock 哪个函数里面的fopen，而其他的使用原始的fopen。直接 include .c 文件另一个好处就是能对 static 函数进行测试。当然这么做的限制也是很大的。</p>
<p>不知 Tony 老师是否试过 CMock 来对付 mock 问题？在对 c 的 mock test 和 static test 还有什么新的方法？</p>
]]></content:encoded>
	</item>
</channel>
</rss>
