读书人

运用bamboo测试框架

发布时间: 2012-07-08 17:43:44 作者: rapoo

使用bamboo测试框架
Bamboo测试框架好用是好用,但是有一套规则,必须按这套规则写,才能顺利地跑起来。

下面是几大规则:

    测试代码必须放在app目录的tests目录下;测试代码的文件必须取名 *_tests.lua;测试代码文件必须引入测试框架:local testing = require 'bamboo.testing';测试代码中使用telescope lua测试工具的结构,所以要学习telescope,不过也很简单;可以在测试代码中创建伪造的浏览器对象,使用这个对象的方法。

关于telescope测试工具的资料:
http://telescope.luaforge.net/
http://telescope.luaforge.net/docs/modules/telescope.html


贴个示例代码:
local testing = require 'bamboo.testing'context("TestApp Testing", function()    context("interaction", function()        test("do it", function()            local tester = testing.browser("tester")            -- click assumes you want a 200 all the time and just returns                         -- the response it got            local resp = tester:click("/")            ptable(resp)            resp = tester:click('/hello/')            ptable(resp)        end)    end)end)

读书人网 >互联网

热点推荐