一个 dsl 的 smoke tool for mobile app 的想法

2015-01-31 13:34:14 +08:00
 lianghui
最近有个想法,想造一个dsl 用来做简单的移动应用的http 冒烟测试。不知大家是否有这种需求,或者提议

[initialize]

@limit = 12
@offset = 24

[index]

> GET /
accept_encoding => gzip, deflate, sdch

code: 200
content <- LoginModal


[item]


> GET /api/channels/1/items limit=@limit offset=@offset

code: 200

json: ['code']=200
json: ['data']['items'][1]['type'] = "post"



上面的dsl将会生成下面的code




class Testtest(WebTestCase):

def setUp(self):
self.client = client
self.initialize()

def initialize(self):
self.limit=12
self.offset=24

def test_index(self):
headers = {}
headers['Accept-Encoding'] = 'gzip, deflate, sdch'
data = {}
self.client.do_request('GET', '/', data, headers)

self.assertCode('200')
self.assertContent('<-', 'LoginModal()')

def test_item(self):
headers = {}
data = {}
data['limit'] = self.limit
data['offset'] = self.offset
self.client.do_request('GET', '/api/channels/1/items', data, headers)

self.assertCode('200')
json = self.client.json
json = json['code']
self.assertJson(json, ':', 200)
json = self.client.json
json = json['data']['items'][1]['type']
self.assertJson(json, ':', "po1st")
1867 次点击
所在节点    Python
3 条回复
reorx
2015-02-01 22:48:20 +08:00
好想法,不过我觉得 DSL 语法不需要自己生造,用已有语法比如 yaml 就好,方便做解析。另外,稍微往远想一点,既然现在已经有一些 web api descriptions language (api blueprint, swagger etc.),不如作为他们的插件存在,这样一份文件既可以描述 API,作为文档,又同时可以生成测试代码,执行测试,就像 doctest 那样,岂不一举两得。

refs:
- https://apiblueprint.org/
- http://swagger.io/
lianghui
2015-02-02 09:31:21 +08:00
@reorx 解析倒不难,基本已经写好了,不过不想做成doc的,因为本身关心的是测试。
reorx
2015-02-02 12:02:26 +08:00
嗯,专注做一件事也不错,希望可以提供生成 nose 写法的选项 XD

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/167011

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX