Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include a test from another file into a test suite #320

Closed
nqb opened this issue Nov 20, 2020 · 4 comments · Fixed by #325
Closed

feat: include a test from another file into a test suite #320

nqb opened this issue Nov 20, 2020 · 4 comments · Fixed by #325
Assignees

Comments

@nqb
Copy link
Contributor

nqb commented Nov 20, 2020

Is your feature request related to a problem? Please describe.
When you want to re-use a test in several test suites, you have two possibilites:

  • duplicate your test in each test suite
  • create a specific test suite for this test and create a symlink to this test suite

Describe the solution you'd like
Be able to include a test inside a test suite at a specific location

Additional context
At the moment, I used a common directory where I put all my common tests in dedicated test suites. Then I use a symlink in each test directory where I want to use this test.

@yesnault
Copy link
Member

Proposal:

executors/custom.yml

executor: custom
input:
  script: {}
steps:
- script: my {{.script}}
- type: exec
  script: echo "foo"
output: 
   result: {{.result.systemout}}

Testsuite.yml

name: Exec testsuite
testcases:
- name: testA
  steps:
  - type: custom
    script: foo
  - type: exec
    script: echo 'foo with a bar here'

venom run Testsuite.yml # will loads all custom executors from executors/ directory

yesnault added a commit that referenced this issue Nov 22, 2020
close #320

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
yesnault added a commit that referenced this issue Nov 22, 2020
close #320

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
@yesnault yesnault self-assigned this Nov 22, 2020
yesnault added a commit that referenced this issue Nov 22, 2020
close #320

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
@nqb
Copy link
Contributor Author

nqb commented Nov 23, 2020

Hello @yesnault,

Thanks for your reply.

In your proposal, I'm not exactly sure to understand what will do this block:

executor: custom
input:
  script: {}
steps:
- script: my {{.script}}

@yesnault
Copy link
Member

yesnault commented Nov 23, 2020

example with a valid user defined executor:

executor: customA
input:
  myarg: {}
steps:
- script: echo "{{.input.myarg}}" > t.log
- script: echo "{\"hello\":\"{{.input.myarg}}\"}"
  assertions:
  - result.code ShouldEqual 0
output:
   systemout: "{{.result.systemout}}"
   systemoutjson.hello: "{{.result.systemoutjson.hello}}"

Here, the executor is named customA. In a testsuite, you can use a customA executor, as you can use a exec executor.

A user defined executor is defined in four part:

  • the name, that you have to use in a testsuite file.
  • the input, that you can set in the testsuite file. You can set a default value to the input in the executor file.
  • the steps: when the customA is executed, the steps are executed.
  • the output: to retrieve the result in the testsuite.

Example of a valid testsuite, using a the executor customA`:

name: testsuite with a user executor
testcases:
- name: testA
  steps:
  - type: customA
    myarg: World
    info: 
    - result of customA is {{.result.systemoutjson.hello}}
    assertions:
    - result.systemoutjson.hello ShouldContainSubstring World

@nqb
Copy link
Contributor Author

nqb commented Nov 23, 2020

I understand and I see how to use it to meet my need: I will have to define a custom executor that run my common test suites.

So when I want to reuse a test between several test suites, I just need to call my executor inside my test suite.

Thanks for this improvement 👏

yesnault added a commit that referenced this issue Nov 23, 2020
close #320

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
fsamin pushed a commit that referenced this issue Nov 23, 2020
* feat: user defined executors

close #320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants