【问题标题】:Cucumber: usage file in scenarioCucumber:场景中的使用文件
【发布时间】:2013-12-18 15:48:32
【问题描述】:

我有以下场景:

Feature: Some feature
   Scenario: Test feature
     Given login as test_user
     When test_user submits changes with content:
        """
        Very long text
        """
     Then content is saved

主要目标是将“非常长的文本”移动到某个文件或类似的文件中,并避免在定义的场景中重复此文本。

【问题讨论】:

    标签: java cucumber integration-testing


    【解决方案1】:

    我只看到一个解决方案(这个解决方案不是很好,但可以用作替代方案):

    Feature: Some feature
       Scenario: Test feature
         Given login as test_user
         When test_user submits changes with content very_long_text.txt            
         Then content is saved
    

    并将very_long_text.txt放入项目测试资源中。可以创建单独的文件夹来保存所有黄瓜资源。例如:src/test/resources/cucumber

    并创建读取此资源内容的实用程序类:

    public static String getText(String fileName){
        IOUtils.toString("cucumber" + fileName);
    }
    

    并以这种方式使用文件内容。为了不重复代码中的消息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-25
      • 1970-01-01
      • 1970-01-01
      • 2017-05-26
      相关资源
      最近更新 更多