Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable in multi-line expression not resolving

Tags:

karate

I have the following scenario that matches the response against a multi-line expression that contains a variable. This variable is defined in karate-config.js and is present because the test succeeds up to the final step.

Background:
  Given url $baseUrl

Scenario: Fetch Root
  Given path "/"
  When method GET
  Then status 200
  And match header Content-Type == $halJson
  And match response ==
  """
  {
    "_links": {
      "user": {
        "href": "$baseUrl/user"
      }
    }
  }
  """

How can I get the baseUrl variable replaced with the real value in the match response step?

like image 367
james.lorenzen Avatar asked Apr 17 '18 20:04

james.lorenzen


People also ask

How do you pass a variable to a multiline string in Python?

In Python, you have different ways to specify a multiline string. You can have a string split across multiple lines by enclosing it in triple quotes. Alternatively, brackets can also be used to spread a string into different lines. Moreover, backslash works as a line continuation character in Python.

How to write multiline string in powershell?

A multiline string is a string whose value exceeds beyond one line. In that, the string should be enclosed within a here-string(@””@). Newline or carriage return value can also be used to create a multiline string. Multiline string can also be defined by using a line break within double-quotes.


1 Answers

With the help of a co-worker I found something that worked

  And match response ==
  """
  {
    "_links": {
      "fpu": {
        "href": '#(baseUrl + "/fpu")'
      }
    }
  }
  """
like image 171
james.lorenzen Avatar answered Oct 17 '22 14:10

james.lorenzen