Skip to content

Latest commit

Β 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Generate GoogleTest/GoogleMock Test Suites for C++ Interfaces

gen_um_test is a toolset for automatic generation of GoogleTest and GoogleMock test suites from C++ pure virtual interface headers.

Developed in python code.

The README is used to introduce the modules and provide instructions on how to install the modules, any machine dependencies it may have and any other information that should be provided before the modules are installed.

gen_um_test python checker gen_um_test package checker gen_um_test interface checker gen_um_test isp checker gen_um_test srp checker GitHub issues open GitHub contributors

Table of Contents

πŸš€ Installation

Used next development environment

debian linux os

gen_um_test python3 build

Currently there are three ways to install package

  • Install process based on using pip mechanism
  • Install process based on build mechanism
  • Install process based on setup.py mechanism
  • Install process based on docker mechanism
Install using pip

gen_um_test is located at pypi.org.

You can install by using pip

# python3
pip3 install gen_um_test
Install using build

Navigate to release page download and extract release archive.

To install gen_um_test type the following

tar xvzf gen_um_test-x.y.z.tar.gz
cd gen_um_test-x.y.z/
# python3
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py 
python3 -m pip install --upgrade setuptools
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build
pip3 install -r requirements.txt
python3 -m build --no-isolation --wheel
pip3 install ./dist/gen_um_test-*-py3-none-any.whl
rm -f get-pip.py
Install using py setup

Navigate to release page download and extract release archive.

To install gen_um_test locate and run setup.py with arguments

tar xvzf gen_um_test-x.y.z.tar.gz
cd gen_um_test-x.y.z
# python3
pip3 install -r requirements.txt
python3 setup.py install_lib
python3 setup.py install_egg_info
Install using docker

You can use Dockerfile to create image/container.

πŸ“¦ Dependencies

gen_um_test requires next modules and libraries

πŸ“ Tool structure

gen_um_test is based on OOP.

Tool structure

Click to expand framework structure
    gen_um_test/
         β”œβ”€β”€ core/
         β”‚Β Β  β”œβ”€β”€ __init__.py
         β”‚Β Β  β”œβ”€β”€ model/
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cpp_interface.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cpp_method.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ generation_result.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __init__.py
         β”‚Β Β  β”‚Β Β  └── test_suite_config.py
         β”‚Β Β  └── service/
         β”‚Β Β      β”œβ”€β”€ engine.py
         β”‚Β Β      β”œβ”€β”€ icmake_generator.py
         β”‚Β Β      β”œβ”€β”€ icpp_parser.py
         β”‚Β Β      β”œβ”€β”€ ifake_generator.py
         β”‚Β Β      β”œβ”€β”€ imock_generator.py
         β”‚Β Β      β”œβ”€β”€ __init__.py
         β”‚Β Β      β”œβ”€β”€ iservice.py
         β”‚Β Β      β”œβ”€β”€ isubprocessor.py
         β”‚Β Β      └── itest_generator.py
         β”œβ”€β”€ engine.py
         β”œβ”€β”€ infrastructure/
         β”‚Β Β  β”œβ”€β”€ cli/
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ engine.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ icli.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __init__.py
         β”‚Β Β  β”‚Β Β  └── setup/
         β”‚Β Β  β”‚Β Β      β”œβ”€β”€ bundle.py
         β”‚Β Β  β”‚Β Β      β”œβ”€β”€ dep_validator.py
         β”‚Β Β  β”‚Β Β      β”œβ”€β”€ dependencies.py
         β”‚Β Β  β”‚Β Β      β”œβ”€β”€ factory.py
         β”‚Β Β  β”‚Β Β      β”œβ”€β”€ __init__.py
         β”‚Β Β  β”‚Β Β      β”œβ”€β”€ keys.py
         β”‚Β Β  β”‚Β Β      β”œβ”€β”€ opt_validator.py
         β”‚Β Β  β”‚Β Β      β”œβ”€β”€ options.py
         β”‚Β Β  β”‚Β Β      β”œβ”€β”€ registry.py
         β”‚Β Β  β”‚Β Β      └── validator.py
         β”‚Β Β  β”œβ”€β”€ command/
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cmake_command_definition.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cmake_command_executor.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ command.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ fake_command_definition.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ fake_command_executor.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ icommand_definition.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ icommand_executor.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __init__.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mock_command_definition.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mock_command_executor.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ suite_command_definition.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ suite_command_executor.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_command_definition.py
         β”‚Β Β  β”‚Β Β  └── test_command_executor.py
         β”‚Β Β  β”œβ”€β”€ config/
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gen_um_test.cfg
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gen_um_test.logo
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ scheme.json
         β”‚Β Β  β”‚Β Β  └── templates.tgz
         β”‚Β Β  β”œβ”€β”€ generator/
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cmake_generator.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ code_formatter.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ fake_generator.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __init__.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ main_generator.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mock_generator.py
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ template_provider.py
         β”‚Β Β  β”‚Β Β  └── test_generator.py
         β”‚Β Β  β”œβ”€β”€ __init__.py
         β”‚Β Β  β”œβ”€β”€ parser/
         β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cpp_parser.py
         β”‚Β Β  β”‚Β Β  └── __init__.py
         β”‚Β Β  β”œβ”€β”€ subprocessor.py
         β”‚Β Β  └── templates/
         β”‚Β Β      β”œβ”€β”€ cmake.template
         β”‚Β Β      β”œβ”€β”€ fake.template
         β”‚Β Β      β”œβ”€β”€ main.template
         β”‚Β Β      β”œβ”€β”€ mock.template
         β”‚Β Β      └── test.template
         β”œβ”€β”€ __init__.py
         β”œβ”€β”€ py.typed
         └── setup/
             β”œβ”€β”€ bundle.py
             β”œβ”€β”€ dep_validator.py
             β”œβ”€β”€ dependencies.py
             β”œβ”€β”€ factory.py
             β”œβ”€β”€ __init__.py
             β”œβ”€β”€ keys.py
             β”œβ”€β”€ opt_validator.py
             β”œβ”€β”€ options.py
             β”œβ”€β”€ registry.py
             └── validator.py

     13 directories, 76 files

✨ Features

  • Parses C++ pure virtual interface header files (.h / .hpp).
  • Synthesizes modern GoogleMock header mocks using MOCK_METHOD(...) with #pragma once.
  • Generates unit test suites (<interface>_test.cc), in-memory fake stubs (fake_<interface>.h), and test runners (test_main.cc).
  • Generates standalone CMakeLists.txt build scripts integrated with GoogleTest and GoogleMock.
  • Configurable template engine structured in templates.tgz with scheme.json schema validation.
  • Provides a modular and extensible architecture based on OOP, SOLID, and Hexagonal principles.
  • Includes command line interface (CLI) support via a command/executor structure.
  • High code quality with full type checking and 100% unit test coverage.

πŸ“Š Code coverage

Click to expand code coverage
Name Stmts Miss Cover
gen_um_test/__init__.py 9 0 100%
gen_um_test/core/__init__.py 9 0 100%
gen_um_test/core/model/__init__.py 9 0 100%
gen_um_test/core/model/cpp_interface.py 43 0 100%
gen_um_test/core/model/cpp_method.py 43 0 100%
gen_um_test/core/model/generation_result.py 19 0 100%
gen_um_test/core/model/test_suite_config.py 23 0 100%
gen_um_test/core/service/__init__.py 9 0 100%
gen_um_test/core/service/engine.py 42 0 100%
gen_um_test/core/service/icmake_generator.py 14 0 100%
gen_um_test/core/service/icpp_parser.py 16 0 100%
gen_um_test/core/service/ifake_generator.py 15 0 100%
gen_um_test/core/service/imock_generator.py 15 0 100%
gen_um_test/core/service/iservice.py 20 0 100%
gen_um_test/core/service/isubprocessor.py 14 0 100%
gen_um_test/core/service/itest_generator.py 15 0 100%
gen_um_test/engine.py 57 0 100%
gen_um_test/infrastructure/__init__.py 9 0 100%
gen_um_test/infrastructure/cli/__init__.py 9 0 100%
gen_um_test/infrastructure/cli/engine.py 39 0 100%
gen_um_test/infrastructure/cli/icli.py 14 0 100%
gen_um_test/infrastructure/cli/setup/__init__.py 9 0 100%
gen_um_test/infrastructure/cli/setup/bundle.py 22 0 100%
gen_um_test/infrastructure/cli/setup/dep_validator.py 36 0 100%
gen_um_test/infrastructure/cli/setup/dependencies.py 18 0 100%
gen_um_test/infrastructure/cli/setup/factory.py 49 0 100%
gen_um_test/infrastructure/cli/setup/keys.py 26 0 100%
gen_um_test/infrastructure/cli/setup/opt_validator.py 36 0 100%
gen_um_test/infrastructure/cli/setup/options.py 15 0 100%
gen_um_test/infrastructure/cli/setup/registry.py 24 0 100%
gen_um_test/infrastructure/cli/setup/validator.py 43 0 100%
gen_um_test/infrastructure/command/__init__.py 9 0 100%
gen_um_test/infrastructure/command/cmake_command_definition.py 24 0 100%
gen_um_test/infrastructure/command/cmake_command_executor.py 28 0 100%
gen_um_test/infrastructure/command/command.py 16 0 100%
gen_um_test/infrastructure/command/fake_command_definition.py 24 0 100%
gen_um_test/infrastructure/command/fake_command_executor.py 28 0 100%
gen_um_test/infrastructure/command/icommand_definition.py 14 0 100%
gen_um_test/infrastructure/command/icommand_executor.py 14 0 100%
gen_um_test/infrastructure/command/mock_command_definition.py 24 0 100%
gen_um_test/infrastructure/command/mock_command_executor.py 28 0 100%
gen_um_test/infrastructure/command/suite_command_definition.py 24 0 100%
gen_um_test/infrastructure/command/suite_command_executor.py 28 0 100%
gen_um_test/infrastructure/command/test_command_definition.py 24 0 100%
gen_um_test/infrastructure/command/test_command_executor.py 28 0 100%
gen_um_test/infrastructure/generator/__init__.py 9 0 100%
gen_um_test/infrastructure/generator/cmake_generator.py 32 0 100%
gen_um_test/infrastructure/generator/code_formatter.py 28 0 100%
gen_um_test/infrastructure/generator/fake_generator.py 57 0 100%
gen_um_test/infrastructure/generator/main_generator.py 26 0 100%
gen_um_test/infrastructure/generator/mock_generator.py 46 0 100%
gen_um_test/infrastructure/generator/template_provider.py 75 0 100%
gen_um_test/infrastructure/generator/test_generator.py 68 0 100%
gen_um_test/infrastructure/parser/__init__.py 9 0 100%
gen_um_test/infrastructure/parser/cpp_parser.py 110 0 100%
gen_um_test/infrastructure/subprocessor.py 122 0 100%
gen_um_test/setup/__init__.py 9 0 100%
gen_um_test/setup/bundle.py 23 0 100%
gen_um_test/setup/dep_validator.py 36 0 100%
gen_um_test/setup/dependencies.py 19 0 100%
gen_um_test/setup/factory.py 58 0 100%
gen_um_test/setup/keys.py 27 0 100%
gen_um_test/setup/opt_validator.py 36 0 100%
gen_um_test/setup/options.py 12 0 100%
gen_um_test/setup/registry.py 24 0 100%
gen_um_test/setup/validator.py 48 0 100%
Total 1908 0 100%

πŸ›  Usage

Install package

pip3 install gen_um_test

Prepare main entry point by downloading main.py or create your own.

wget -O main.py https://raw.githubusercontent.com/electux/gen_um_test/main/main.py

Running tool for generating complete GoogleTest suite:

python3 main.py suite --interface include/ISerialPort.h --output ./tests --prefix comm

Running tool for generating individual components:

python3 main.py mock --interface include/ISerialPort.h --output ./tests
python3 main.py test --interface include/ISerialPort.h --output ./tests
python3 main.py fake --interface include/ISerialPort.h --output ./tests
python3 main.py cmake --interface include/ISerialPort.h --output ./tests

πŸ“š Docs

Documentation Status

More documentation and info at

πŸ‘₯ Contributing

Contributing to gen_um_test

πŸ“„ Copyright and licence

License: GPL v3 License

Copyright (C) 2026 by vroncevic.github.io/gen_um_test

gen_um_test is free software; you can redistribute it and/or modify it under the same terms as Python itself, either Python version 3.x or, at your option, any later version of Python 3 you may have available.

Lets help and support PSF.

Python Software Foundation

Donate

Releases

Packages

Contributors

Languages