Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
928 views
in Technique[技术] by (140 points)

LuaMock-一个使用起来超级方便的Lua Mock框架

LuaMock

一个使用起来超级方便的Lua Mock框架
https://github.com/ostack/luamock

(A very simple and easy use Lua Mock Framwork)

欢迎大家到 http://www.ostack.cn 交流编程经验

TODO

目前只支持对table表中声明的函数进行mock,后续考虑支持mock全局函数,不过因为lua 5.1和5.3 版本对全局env的方式不同,所以尚未考虑好怎么处理。 如果您对全局函数的Mock有任何想法或者建议的话,欢迎给我们提交issue,或者联系QQ/微信:316848526

Right now, we only support to mock the function which is declared in table, and we consider to support mock global function in few months, as the gloable env in lua vession 5.1 and 5.3 are different ,so I do not have any good idea to deal this problem ,if you have any suggestion ,welcome leave an issue or connect us with QQ/WeChat:316848526

使用示例(use example)sample.lua

local Mock = require("Mock")

local function testFoo()

local TestMock = Mock:new("TestMock")

TestMock:mock("foo", "outputPara", 1)

print(TestMock.foo())

print(TestMock.foo())

TestMock:verify()

end

return testFoo()

Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...