Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
775 views
in Technique[技术] by (71.8m points)

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

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

question from:https://stackoverflow.com/questions/65516909/com-intuit-karate-exception-karateexception-negative-feature113-javascript-e

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...