call the first feature from the second feature file, failed without specified clue

…衆ロ難τιáo~ 提交于 2021-02-05 07:51:30

问题


Run the first.feature file successfully,however, call it from the second.feature failed without any clue to analysis. Do you have any idea help me find the root cause?

The source of my first.feature:

Feature: 采样管理-样本登记

  Background: 读取随机生成的条形码、手机号、采样类型等作为入参
    * url baseURL

    * def randomData = Java.type('utils.RandomData')
    * def barcode = randomData.getRandom(11)
    * def randomPhone = randomData.getTelephone()
    * def sampletype = randomData.getNum(0,1)

  Scenario: 输入合法参数进行正常样本登记,确认能够登记成功

    Given path 'iEhr/PersonSample'
#    * header Content-type = 'application/x-www-form-urlencoded; charset=UTF-8'
    * cookies { JSESSIONID: '#(jsessionID)',SESSION: '#(sessionID)', ACMETMP: '#(acmetmpID)'}
    * def autoMotherName = "autoMname"+ barcode

#    * def confData = {mothername: "#(autoMotherName)", barcode: "#(barcode)", mobile: '#(randomPhone)', sampletype:"#(sampletype)" }
#   设置sampletype为1,已被采样
    * def confData = {mothername: "#(autoMotherName)", barcode: "#(barcode)", mobile: '#(randomPhone)', sampletype:"1" }
#    打印入参变量输出
    * print confData

#    用例与数据分离
    * def paramObj = read('classpath:mainFlow/sampleSaveReqTest.json')
    * print paramObj
    * form field param = paramObj

    When method post

    Then status 200
    * json result = response[0].result
    * def personId = result[0].personid
    * def sampleid = result[0].sampleid
    * print personId
    * print sampleid

The source of my second.feature:

Feature: 提交递送样本
  Background:

    * def sampleResult = call read('classpath:mainFlow/first.feature')
    * print sampleResult

I run the first.feature singly, it works. However, karate reports the error below after running the second.feature. Any idea how can I debug to find the root cause? I have no idea what's wrong with the second read. Many thanks!

* def sampleResult = call read('classpath:mainFlow/first.feature')

-unknown-:14 - javascript evaluation failed: read('classpath:mainFlow/first.feature'), null


回答1:


Look for some issue with karate-config.js. As Babu said in the comments, it is very hard to make out what the problem is, I suggest you follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Also try if the latest preview version 0.9.3.RC2 is better at showing what the error is.

If you can replicate the problem as a small example, it will help us - because we really need to do better at showing more useful error logs, instead of just null.



来源:https://stackoverflow.com/questions/56213967/call-the-first-feature-from-the-second-feature-file-failed-without-specified-cl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!