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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀