lua-users home
lua-l archive
Re: Is there similar autospeccing thing in lemock?
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
] [
Date Index
] [
Thread Index
]
Subject
:
Re: Is there similar autospeccing thing in lemock?
From
: albert_200200 <albert_200200@
...
>
Date
: 2014年8月11日 17:39:52 +0800
On 2014年8月8日 11:24, albert_200200 wrote:
[
lunit.setprivfenv()
lunit.import "assertions"
lunit.import "checks"
require("lemock")
local ut = lunit.TestCase("public.add function test")
function ut:test()
local public = require("public")
mc = lemock.controller()
mock_add_internal = mc:mock()
package.loaded.public.add_internal = mock_add_internal
mock_add_internal(2, 3); mc:returns(5)
mc:replay()
local result = public.add(2, 3)
assert_equal(5, result)
mc:verify()
end
lunit.run()
Now take such situation, I modify public.add_internal'code as below:
public.lua
---------------------------------------------------
local M = {}
function M.add_internal(a, b, c)
return a+b+c
--add_internal may call some global function, so I should mock add_internal
end
function M.add(a, b)
return M.add_internal(a, b)
end
return M
But I leave the test.lua unmodified, the unittest would pass too.
Is there a way to solve this problem? Could someone know how to solve this problem? It really bothers me for a while.
Follow-Ups
:
Re: Is there similar autospeccing thing in lemock?
,
Volodymyr Bezobiuk
References
:
Is there similar autospeccing thing in lemock?
,
albert_200200
Prev by Date:
5.3.0-alpha advanced readline patch
Next by Date:
Re: Local Variables
Previous by thread:
Is there similar autospeccing thing in lemock?
Next by thread:
Re: Is there similar autospeccing thing in lemock?
Index(es):
Date
Thread
AltStyle
によって変換されたページ
(->オリジナル)
/
アドレス:
モード:
デフォルト
音声ブラウザ
ルビ付き
配色反転
文字拡大
モバイル