使用bamboo测试框架

本文介绍了Bamboo测试框架的使用规则,包括测试代码的位置、文件命名、框架引入等,并提供了一个使用telescope测试工具的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

下面是几大规则:
[list=1]
[*]测试代码必须放在app目录的tests目录下;
[*]测试代码的文件必须取名 *_tests.lua;
[*]测试代码文件必须引入测试框架:local testing = require 'bamboo.testing';
[*]测试代码中使用telescope lua测试工具的结构,所以要学习telescope,不过也很简单;
[*]可以在测试代码中创建伪造的浏览器对象,使用这个对象的方法。
[/list]
关于telescope测试工具的资料:
[url]http://telescope.luaforge.net/[/url]
[url]http://telescope.luaforge.net/docs/modules/telescope.html[/url]


贴个示例代码:

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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值