svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 325 forks source link

Nested includes #254

Open jacksonofalltrades opened 7 years ago

jacksonofalltrades commented 7 years ago

Let me start by expressing my appreciation. This is a fantastic framework, thanks for building it!

It would be great if I could include one test yaml file inside another just to be able to more modularly organize my tests, but still run all of them with one command-line.

For example:

main.yaml
   include: a.yaml
   include: b.yaml

a.yaml
- test:
     do stuff
- test:
     do more stuff

b.yaml
- test: ...

So this way I could group my tests for the API and make it easier to maintain or have different people work on different groups of tests.

Thanks! -Dave

j796160836 commented 7 years ago

Hi @jacksonofalltrades, I also using this awesome framework. I think it does have import command, by using import keyword. But the variable is independent between child and parent.

- import: a.yaml

See more here https://github.com/svanoort/pyresttest#import-example

j796160836 commented 7 years ago

I'm looking for global variables define, details here. https://github.com/svanoort/pyresttest/issues/256

sfoley commented 6 years ago

Im new to this framework (coming from the pytest mindset), but Im liking it already. I tried to nest some import statements, but Im getting a path problem. Maybe Im not approaching this right, but Id like to setup some re-usable fixtures to put my backend between tests. I create something like:

add_fixture.yaml:

-test:
  - name: "Add simple item"
  - url: "/endpoint/"
  - method: "POST"
  - body: '{"id": "test_id", "value": 123}

This works fine when import this into a series of tests via something like: test_additions.yaml:

  - import add_fixture.yaml
  - test:
    - ...and so on...

However, when I have something like all_tests.yaml:

  - import test_additions.yaml
  - ...

it chokes on the path for the fixture.yaml file. Looks like this is a working directory issue. Am I doing something wrong here, or is this a bug? Maybe there is another way to aggregate tests into "suites" with pyresttest?