Manage and run your integration tests with efficiency - Venom run executors (script, HTTP Request, web, imap, etc... ) and assertions
Manage and run your integration tests with efficiency - Venom run executors (script, HTTP Request, web, imap, etc... ) and assertions
Venom is a CLI (Command Line Interface) that aims to create, manage and run your integration tests with efficiency.
Venom allows you to handle integration tests the same way you code your application. With Venom, testcases will be managed as code: the readability of the tests means that the tests are part of the code reviews. Thanks to that, writing and executing testsuites becomes easier for developers and teams.
Concretely, you have to write a testsuite in a YAML file. Venom runs executors (scripts, HTTP Request, web, IMAP, etc.) and applies assertions. It can also generate xUnit result files.
You can find the latest binary release at: https://github.com/ovh/venom/releases/latest/.
Example for Linux:
$ curl https://github.com/ovh/venom/releases/download/v1.2.0/venom.linux-amd64 -L -o /usr/local/bin/venom && chmod +x /usr/local/bin/venom
$ venom -hYou can update to the latest version with venom update command:
$ venom updateThe venom update command will download the latest version and replace the current binary:
Url to update venom: https://github.com/ovh/venom/releases/download/v1.2.0/venom.darwin-amd64
Getting latest release from: https://github.com/ovh/venom/releases/download/v1.2.0/venom.darwin-amd64 ...
Update done.Check the new version with venom version command:
$ venom version
Version venom: v1.2.0 Instead of installing (and updating) Venom locally, Venom can be started as a Docker image with the following commands.
Considering your testsuites are in ./tests directory in your current directory and your test library is under ./tests/lib, the results will be available under the results directory.
$ mkdir -p results
$ docker run --mount type=bind,source=$(pwd)/tests,target=/workdir/tests --mount type=bind,source=$(pwd)/results,target=/workdir/results ovhcom/venom:latest Please refer to https://hub.docker.com/r/ovhcom/venom/tags to get the available image tags.
venom CLI is composed of several commands:
$ venom -h
Venom - RUN Integration Tests
Usage:
venom [command]
Available Commands:
help Help about any command
run Run Tests
update Update venom to the latest release version: venom update
version Display Version of venom: venom version
Flags:
-h, --help help for venom
Use "venom [command] --help" for more information about a command.You can see the help of a command with venom [command] -h:
…venom run 01_foo.yml 02_foo.yml will run 01 before 02. venom run 02_foo.yml 01_foo.yml will run 02 before 01.If you want to sort many testsuite files, you can use standard commands, example:
venom run `find . -type f -name "*.yml"|sort`The venom CLI supports globstar:
$ venom run ./foo/b*/**/z*.ymlTo specify individual variables on the command line, use the --var option when running the venom run commands:
$ venom run --var="foo=bar"
$ venom run --var='foo_list=["biz","buz"]'
$ venom run --var='foo={"biz":"bar","biz":"barr"}'The --var option can be used many times in a single command.
To set a lot of variables, it is more convenient to specify their values in a variable definitions file. This file is a YAML dictionary. You have to specify that file on the command line with --var-from-file:
venom run --var-from-file variables.yamlAs a fallback for the other ways of defining variables, venom tool searches the environment of its own process for environment variables named VENOM_VAR_ followed by the name of a declared variable.
$ export VENOM_VAR_foo=bar
$ venom run *.ymlYou can also define the environment variable and run your testsuite in one line:
$ VENOM_VAR_foo=bar venom run *.ymlYou can define arguments on the command line using the flag name.
Flags are listed in the result of help command.
List of available flags for venom run command:
…You can also define the arguments with environment variables:
# is the same as
VENOM_FORMAT=json venom run my-test-suite.yml
# is equivalent to
venom run my-test-suite.yml --format=jsonFlags and their equivalent with environment variables usage:
--format="json" flag is equivalent to VENOM_FORMAT="json" environment variable--lib-dir="/etc/venom/lib:$HOME/venom.d/lib" flag is equivalent to VENOM_LIB_DIR="/etc/venom/lib" environment variable--output-dir="test-results" flag is equivalent to VENOM_OUTPUT_DIR="test-results" environment variable--stop-on-failure flag is equivalent to VENOM_STOP_ON_FAILURE=true environment variable--var foo=bar flag is equivalent to VENOM_VAR_foo='bar' environment variable--var-from-file fileA.yml fileB.yml flag is equivalent to VENOM_VAR_FROM_FILE="fileA.yml fileB.yml" environment variable-v flag is equivalent to VENOM_VERBOSE=1 environment variable-vv flag is equivalent to VENOM_VERBOSE=2 environment variableIt is possible to set NO_COLOR=1 environment variable to disable colors from output.
You can define the Venom settings using a configuration file .venomrc. This configuration file should be placed in the current directory or in the home directory.
variables:
- foo=bar
variables_files:
- my_var_file.yaml
stop_on_failure: true
format: xml
output_dir: output
lib_dir: lib
verbosity: 3Please note that the command line flags override the configuration file. The configuration file overrides the environment variables.
A test suite is a collection of test cases that are intended to be used to test a software program to show that it has a specified set of behaviors. A test case is a specification of the inputs, execution conditions, testing procedure, and expected results that define a single test to be executed to achieve a particular software testing objective, such as to exercise a particular program path or to verify compliance with a specific requirement.
In venom the testcases are executed sequentially within a testsuite. Each testcase is an ordered set of steps. Each step is based on an executor that enables some specific kind of behavior.
In venom a testsuite is written in one YAML file respecting the following structure:
…exec is the default type for a stepYou can define an executor with a single YAML file. This is a good way to abstract technical or functional behaviors and reuse them in complex testsuites.
Example:
file lib/customA.yml:
executor: hello
input:
myarg: {}
steps:
- script: echo "{\"hello\":\"{{.input.myarg}}\"}"
assertions:
- result.code ShouldEqual 0
vars:
hello:
from: result.systemoutjson.hello
all:
from: result.systemoutjson
output:
display:
hello: "{{.hello}}"
all: "{{.all}}"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 WorldNotice the variable alljson. All variables declared in output are automatically converted into JSON format with the suffix json. In the example above, two implicit variables are available: displayjson.hello and alljson.
Venom will load user-defined executors from the directory lib/ relative to the testsuite path. You can add executor source paths using the flag --lib-dir.
Note that all folders listed with --lib-dir will be scanned recursively to find .yml files as user executors.
The user defined executors work with templating, you can check the templating result in venom.log. In this file, if you see an error such as error converting YAML to JSON: yaml: line 14: found unexpected end of stream, you probably need to adjust indentation with the templating function indent.
Example:
name: testsuite with a user executor multilines
testcases:
- name: test
steps:
- type: multilines
script: |
# test multilines
echo "5"
assertions:
- result.alljson ShouldEqual 5using this executor:
executor: multilines
input:
script: "echo 'foNo open issues yet, or sync has not completed.