cucumber系列(一) 如何让cucumber识别中文

1,由于有时候找不到对应的英文描述现有产品的一些功能,所以准备支持中文来写cucumber 框架。

在命令行执行如下命令可查看在写feature文档时的关键字对应,如“功能”,”背景“,”假如“等等。

#cucumber --i18n zh-CN 
      | feature          | "功能"       |  
      | background       | "背景"       |  
      | scenario         | "场景"       |  
      | scenario_outline | "场景大纲"    |  
      | examples         | "例子"       |  
      | given            | "* ", "假如" |  
      | when             | "* ", "当"   |  
      | then             | "* ", "那么" |  
      | and              | "* ", "而且" |  
      | but              | "* ", "但是" |  
      | given (code)     | "假如"       |  
      | when (code)      | "当"         |  
      | then (code)      | "那么"       |  
      | and (code)       | "而且"       |  
      | but (code)       | "但是"       | 

 

2, 在feature文件里的第一行要写 language:zh-CN, 不然cucumber无法认出中文

#language: zh-CN

3, 当然同时在rb文件里头部加上

#encoding:utf-8

posted @ 2014-04-17 16:40  纵情向前....  阅读(2014)  评论(0编辑  收藏  举报