1

I use common.yaml file for sharing stages but If I add more than one stage it's showing error "tavern.util.exceptions.UnexpectedDocumentsError:". Do I have to add separate yams file for each stage?

My common.yaml file

name: Test /order endpoint status code and response
description:
  Reusable test stage to get listings

stages:
  - id: get_listings
    name: Test to get all the listings 
    request:
       url: 
      method: POST
      headers:
        Authorization: 
 ---
name: Test /status endpoint to create order
description:
  Reusable test stage for order creation

stages:
  - id: create_order
    name: Test to create an order
    skip: False
    request:
      url: 
      method: POST
      headers:
        Authorization: 

Testfile.yaml

test_name: Test endpoint

includes:
 - !include common.yaml

stages:

  - type: ref

    id: get_listings

  - type: ref1

    id: create_order
halfer
  • 19,824
  • 17
  • 99
  • 186
Sara
  • 19
  • 6
  • When presenting code, config or logs here, please use the formatting tool provided in the editor. Markdown format is supported. – halfer Apr 02 '20 at 13:12
  • 1
    Sorry about that..I will keep this in mind..Thanks – Sara Apr 02 '20 at 13:19

1 Answers1

1

!include cannot handle a file with multiple documents since it basically replaces the current node with the content from the referred document, starting at its root node. Since a file with multiple documents has multiple root nodes, it's unclear what !include should do there.

That being said, you can of course simply define both stages in the same document:

# [snip]

stages:
  - id: get_listings
    name: Test to get all the listings 
    request:
       url: 
      method: POST
      headers:
        Authorization:
  - id: create_order
    name: Test to create an order
    skip: False
    request:
      url: 
      method: POST
      headers:
        Authorization: 
flyx
  • 35,506
  • 7
  • 89
  • 126