dpjhq00684 2014-07-24 03:52
浏览 32
已采纳

如何让behat知道使用哪个功能上下文?

how to let behat know which context to use?, because by default,there is this FeatureContext.php inside the features folder, whereby, when the behat runs, it will use that file while the .feature file is running (scenarios)...the problem is, if I have alot of modules to test, ofcourse, I cannot just lump all of those functions inside one FeatureContext.php file right?, I would want to name different contexes and different .feature files, so how to let behat know which context and .feature file to run?

this is the line of command that i use to fire behat

/export/home/project/htdocs/bdd/bin/behat --profile phantomjs-via-webdriver
  • 写回答

1条回答 默认 最新

  • drt12345678 2014-07-24 06:28
    关注

    Behat uses all of the contexts you specify, the only way out of this is to specify only the context(s) you want to use. Depending on the Behat version the syntax also differs. For Behat 2 this answer explains one strategy. For Behat 3 you can do the following:

    default:
        suites:
            module1:
                contexts:
                    - 'FeatureContext1'
                    - 'FeatureContext2'
            module2:
                contexts:
                    - 'FeatureContext1'
                    - 'FeatureContext3'
    

    My two cents: I don't have a tiniest idea about your app, but don't confuse functional and unit testing (if you do). There can be different situations when you benefit from per module contexts, like "authorisation", "admin", or "comments", but their only purpose is to separate code from the overall context into a more manageable chunks. They still work together and cover the entire application (or a very distinct part of it). Testing module-specific functionality would be a lot easier with a unit test framework, which ensures that the modules works on their own.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM