Testing with vynetest

Learn to carry out tests

vynetest is a command line tool that lets you execute tests. It's designed to be run as part of a test-driven CI/CD approach to taxonomy design.

Getting the test tool

The test tool is available to download here. The tool is built using Java, and you are expected to have a JRE installed.

We ship scripts for running vynetest on either Windows or Linux/Mac environments.

  • bin/vynetest.bat for Windows
  • bin/vynetest for Mac and Linux

Download, and unzip the tools. For the best experinece, we recommend adding the vynetest command to your PATH.

Docker image

Alternatively, a docker image is available on Docker Hub at vyneco/vynetest

docker pull vyneco/vynetest:latest

The docker image expects to find the base taxi project mounted as a volume named /work. Therefore, execution of tests using docker might look something like the following:

docker run -v ${PWD}:/work vyneco/vynetest

The docker image defaults to running the test command, but this can be overridden by specifying a command.

For example, to show the version of the tool bundled into the docker image, execute the following:

docker run -v ${PWD}:/work vyneco/vynetest -v

Help & Version

Executing vynetest will give you a list of the available commands

vynetest -v will show the version installed.

Model parsing tests

Model parsing tests allow you to test data feeds are parsed correctly against their Taxi based definitions

Running a test

From within a directory containing tests, execute:

vynetest test
Usage: testcli test [-p=<specPath>]
  -p, --path=<specPath>   The directory of specs

This will search for test spec files below the current directory.

You can optionally specify a path to search by using the -p or --path options.

Typical project layout

├── src/
│   └── sample.taxi
├── tests/
│   └── hello-world/
│       ├── hello-world.spec.json
│       ├── input.csv
│       └── expected-output.json
└── taxi.conf
You can choose any layout you wish, what we've provided is a recommended standard, but the tooling is fairly flexible. Consider the following rules
  • vynetest will look downward in each folder and subfolder recursively for test files (*.spec.json)
  • For each test spec file it finds, vynetest will look upwards for a taxi.conf file defining the taxonomy to use to test with

Layout of a test case

Each test is a directory containing at least 3 files:

  • A spec config file
  • An input to parse
  • An expected output


└── hello-world/  (A directory containing a single test)
    ├──  hello-world.spec.json (The spec)
    ├── input.json (The input to parse)
    └── expected.json (A file describing the expected result of parsing)

Spec config file

This is a JSON file defining the configuration of the specific test case.

It can be named anything, but must end with spec.json.

By convention, we suggest naming the file after the name of the test.

eg: simple-hello-world.spec.json

A minimal spec contains the following parts:

  • name: the name of the test, displayed in test output
  • source: the source file to be read
  • expected: the expected output. Normally, this is obtained by downloading from within Vyne's Data Explorer.
  • targetType: The type which the input should be projected against.

Here's a sample file:

  "name": "simple hello world",
  "source": "input.json",
  "expected": "expected.json",
  "targetType": "vyne.demo.Person"

Expected output

The expected file is a specific format generated by Vyne. It's a JSON file describing the expected results of parsing the input.

The easiest way to create an expected output file, is to generate on through Vyne's Data Explorer

Generating a Test Spec through Vyne

The entire test spec can be generated through Vyne's UI.

Import a file into Vyne's data explorer as you would normally, specifying the type.

The parsed content appears in the Parsed Data tab. Click to download - and choose to download as a test spec:

Click to download as a test spec

When prompted, provide a name for the test, and click Download

A zip file containing the 3 files required is downloaded. Unzip the file into the directory within your taxonomy containing the tests