Venom 🐍 1.0 – Manage and run your integration tests with efficiency

Venom, our tool that aim to manage and run your integration tests with efficiency, have been released few weeks ago in 1.0!

We will discover in this blog post, new features and changes contained in this major release.

Venom

Venom is a tool written in Golang, created in 2017, open-sourced and available on GitHub. It allows you to write and execute integration tests.

Concretely, you have to write testsuite in a YAML file. Venom run executors (scripts, HTTP Request, web, IMAP, etc.) and apply assertions. It can also generate xUnit result files.

The tool has a list of existing executors:

One of the powers of Venom is that it fits very well into a CI/CD pipeline.

Venom allows an export of the result in xUnit format and you can pass parameters from your CI/CD tool to the testsuites:

$ venom run mytestsuite.yml --var url=http://myurl.dev/myendpoint --format=xml --output-dir="test-results"

A good practice can be to add the execution of this command as a step of your pipeline and thus use your preferred tools to visualize the results of the tests in order to know if there was no regression between two runs of your CI/CD pipeline for example.

Venom also supports TLS & mTLS for HTTP executor and a lot of cool features.

What’s new?

Venom 1.0, contains interesting new features compared to the previous version 0.28:

User-defined executors: https://github.com/ovh/venom/tree/v1.0.0#user-defined-executors

New builtin executors: amqp & mqtt

The output of venom command line (CLI) was rewritten. It’s much more readable with color and you can now debug testsuite.

Variables helpers: https://github.com/ovh/venom/tree/v1.0.0#variable-helpers

You can take a look at all other cool features in the Release Note: https://github.com/ovh/venom/releases/tag/v1.0.0

User-defined executors

Let’s see in details this new feature.

You can define reusable testcase as executor, and call it from your testsuite files. This is a good way to abstract technical or functional behaviors and reuse them in complex test suites.

You just have to define your executor in a YAML file and then call it in your testsuite.

Example:

Create a lib/ folder. Then into it create a file called customA.yml:

executor: hello
input:
  myarg: {}
steps:
- script: echo "{\"hello\":\"{{.input.myarg}}\"}"
  assertions:
  - result.code ShouldEqual 0
output:
  display:
    hello: "{{.result.systemoutjson.hello}}"
  all: "{{.result.systemoutjson}}"

Then outside of lib/ folder, create you test suite in a file testsuite.yml:

name: testsuite with a user executor
testcases:
- name: testA
  steps:
  - type: hello
    myarg: World
    assertions:
    - result.display.hello ShouldContainSubstring World
    - result.alljson.hello ShouldContainSubstring World

Notice the variable alljson. All variables declared in output are automatically converted in a json format with the suffix json. In the example above, two implicit variables are available: displayjson.hello and alljson.

You should have this files and folder organization:

.
├── lib
│   └── customA.yml
└── testsuite.yml

1 directory, 2 files

Now we can execute our test suite. By default, Venom will load user’s executors from the lib/ directory relative to the testsuite path:

# executors will be loaded from lib/ directory relative to testsuite.yml file
$ venom run testsuite.yml
• testsuite with a user executor (testsuite.yml)
• testA SUCCESS

Note : if you want to add some external libs you wrote in others folder, you can with the --lib-dir flag.

# executors will be loaded from /etc/venom/lib, $HOME/venom.d/lib and lib/ directory relative to testsuite.yml file
$ venom run --lib-dir=/etc/venom/lib:$HOME/venom.d/lib testsuite.yml 

Conclusion

With Venom, test cases can be managed like code: the readability of the test description means that the tests are part of the code reviews. Thanks to that, write and execute testsuites become easier for developers and teams.
We hope this blog post will help you to discover Venom & its new features. Don’t hesitate to give us feedbacks about it. You can also contribute, you can create issues and/or Pull requests(PR) in Venom GitHub repository.

DevRel at OVHcloud | + posts

DevRel - Google Developer Expert on Cloud - Docker captain - CNCF Ambassador - CKAD - Speaker - Sketchnoter - Technical writer - Conferences organizer - Women in tech association Leader - Mentor