新一代BDD框架Gauge+Taiko( 二 )

  • Taiko采用隐式的等待(Wait)方式,也可以手动设置超时时间以防有些访问等待时间过长 。这种隐式等待相比其他自动化工具需要手动设置等待时间的显式等待方式要更高效、更稳定 。
  • 与Gauge的完美结合:Taiko在REPL里执行的浏览器操作步骤,可以通过一个简单的命令直接生产Gauge支持的Step,只需要再去简单的加上step名称就可以,操作及其简单 。
  • Gauge+Taiko的代码长这样:
    Spec定义
    # Google SearchThis is an executable specification file. This file follows markdown syntax. Every heading in this file denotes a scenario. Every bullet point denotes a step.To execute this specification, usenpm test## Finding some cheese* Goto Google search page* Google for "Cheese!"* Page title starts with "Cheese"Steps实现
    step("Goto Google search page", async function() {await goto("www.google.com");});step("Google for <query>", async (query) => {await write(query);await click("Google 搜尋");});step("Page title starts with <content>", async (content) => {await title().then((pageTitle) =>{assert.ok(pageTitle.startsWith(content));});});总结协作是人的问题,工具可以起到辅助作用,但是不能解决根本问题,过于严格的工具缺乏灵活性,反而阻碍了高效协作的可能 。
    Gauge不强调协作,可以作为自动化测试工具独立存在,同时又支持高效协作、支持实现BDD,是一款灵活性更好的框架 。它的秘密武器Taiko是一款优秀的Web UI自动化工具,两者的结合堪称完美,让需求规范、自动化测试和活文档的有机结合真正成为可能 。
    本文只是将Gauge和Taiko跟Cucumber框架从对BDD的角度做简单的对比,更多的关于Gauge和Taiko的高级特性,请参考【延伸阅读】部分相关文章 。
    延伸阅读
    • 说起BDD,你会想到什么:https://www.bylinzi.com/2015/06/04/when-we-talk-about-bdd/
    • Gauge:https://gauge.org/
    • Taiko:https://taiko.gauge.org/
    • Why I chose Gauge over Cucumber:https://medium.com/@divi6.1990/why-i-chose-gauge-over-cucumber-5b3de478d889
    • TEST AUTOMATION WITH GAUGE:http://www.santiagomontesinos.com/test-automation-with-gauge/
    文/ThoughtWorks 林冰玉




    推荐阅读