当我尝试在空手道中使用javascript时遇到gherking.lexer.lexingError

时间:2018-08-21 19:52:44

标签: javascript cucumber karate

JavascriptUtil.feature

Feature: test soap end point

Background: 

* def randomString = function(){ 
                return Math.floor(100000000 + Math.random() * 900000000);}

***方案:

TestFeature文件

@smoke@sanity
Feature: test soap end poin

Background: 
   * url    'URL of the API'

   * call read('JavascriptUtil.feature')

Scenario:   Test

 * def temp = randomPhoneString()
 * print temp

我得到的错误是:

  

原因:gherkin.lexer.LexingError:第6行出现Lexing错误:“返回Math.floor(100000000 + Math.random()* 900000000);}

1 个答案:

答案 0 :(得分:1)

请删除换行符,或使用"""“ doc_string”语法-refer documentation

* def randomString = function(){ return Math.floor(100000000 + Math.random() * 900000000) }