Skip to main content

Unit test helper

Project description

Quality Gate Status

VTunit

This is a unit test/mock framework based on Unity and fff, aimed for embedded developers.

Installation

Install the package with pip

  • pip install -e git+https://github.com/vtunr/VTunit.git#egg=VTunit
  • pip install -e . if you clone the repository (for development purpose)

Package to install (if you choose local build)

On ubuntu/WSL :

  • sudo apt-get install cmake ninja-build ruby
  • You'll also need universal_ctag :
git clone https://github.com/universal-ctags/ctags.git
cd ctags
./autogen.sh 
./configure
make
sudo make install

Setup unit test for a project

  • python -m vtunit {path_unit_test} init

Creating a new unit test

  • python -m vtunit {path_unit_test} new --file_name {my_file_name.c}

It will generate into the test folder:

  • test_{file_to_test}.c
  • test_{file_to_test}.cmake

You then need to add the c file you want to compile for your test in the test_{file_to_test}.cmake.

You can also add include in include.cmake

Automatic mocking

You can automatically mock header.

You just need to add mock_ prefix to the header you want to include :

#include "mock_my_header.h"

#include "mock_my_folder/my_header.h"

Prebuild / Postbuild

There is a way to run command before and after build (not after run)

You need to add :

  • list(APPEND PREBUILD_CMD && cmd_you_want) in prebuild.cmake
  • list(APPEND POSTBUILD_CMD && cmd_you_want) in postbuild.cmake

Running test

Running in WSL or linux :

  • If you want to force calling cmake (need to be done once before calling run): python -m vtunit {path_unit_test} build --clean_all --cmake
  • Then to build and run : python -m vtunit {path_unit_test} build --run
  • To clean : python -m vtunit {path_unit_test} build --clean

You can also filter the test you want to run :

  • To list : python -m vtunit {path_unit_test} build --list --filter {my_regex} (optional --filter)
  • To filter : python -m vtunit {path_unit_test} build --run --filter {my_regex}

You can also ignore prebuild/postbuild command by adding --ignore_prebuild and --ignore_postbuild

TODO :

  • Improve argparse
  • Add possibility to run it in a docker container

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

VTunit-0.0.1a0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

VTunit-0.0.1a0-py2-none-any.whl (9.2 kB view details)

Uploaded Python 2

File details

Details for the file VTunit-0.0.1a0.tar.gz.

File metadata

  • Download URL: VTunit-0.0.1a0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/2.7.17

File hashes

Hashes for VTunit-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 61544d8e56381be7c1163c7a35a9e691f8d037e622dbac79d1c5412a32b09379
MD5 a8565a49bffa615a248d687af74c2603
BLAKE2b-256 ead7295eb07ae8d375e85a6f6e0fd20b617047a17f262d3b9327bf3bc19a94ad

See more details on using hashes here.

File details

Details for the file VTunit-0.0.1a0-py2-none-any.whl.

File metadata

  • Download URL: VTunit-0.0.1a0-py2-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/2.7.17

File hashes

Hashes for VTunit-0.0.1a0-py2-none-any.whl
Algorithm Hash digest
SHA256 06aae6913495fb6a8e5b906a01c8c98dce8ed68b898defc9a6e1530c53aca8b5
MD5 6fd56130ba8b828bd49799fd01be2075
BLAKE2b-256 10c1d389e15e0575c24968e33d0d0cafb95c0a97d955e0fe7ad2f43cfbcb6b06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page