Skip to content
Ronika-CoPublic

About

Generate mock/stub SDK layers for embedded unit testing. generate stub headers with function-pointer overrides for every API your project uses. Swap out hardware-dependent calls in unit tests without any mock framework.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

mockware

Generate mock SDK implementations for embedded unit testing from YAML templates.

Describe your external SDK headers (ESP-IDF, FreeRTOS, OpenThread, etc.) in a YAML file and mockware produces compilable stubs with overridable function pointers for C and virtual methods for C++.

Quick start

# Download a pre-built binary from GitHub Releases:
# https://github.com/Ronika-Co/Mockware/releases
#
# Or run directly from source:
git clone https://github.com/Ronika-Co/Mockware.git
cd Mockware

# Generate mock SDK from all templates
uv run mockware generate examples/sample_project/templates/ -o mock-sdk

Then compile your tests with -I mock-sdk/include and link mock-sdk/source/*.c.

Documentation

Full documentation: https://ronika-co.github.io/Mockware/

Example

# template.yml
headers:
  "esp_err.h":
    macros:
      ESP_OK: "0"
    types:
      esp_err_t: int

  "driver/gpio.h":
    includes: ["esp_err.h"]
    functions:
      gpio_set_level:
        return: esp_err_t
        params: ["int pin", "int level"]
mockware generate template.yml -o mock-sdk
// test.c
#include "mockware/fakes.h"

void test() {
    gpio_set_level_mock = &my_stub;
    gpio_set_level(1, 1);  // calls my_stub
}

Development

uv sync --group dev
uv run mockware --help
uv run pytest tests/ -v
uv run ruff check src/ tests/

About

Generate mock/stub SDK layers for embedded unit testing. generate stub headers with function-pointer overrides for every API your project uses. Swap out hardware-dependent calls in unit tests without any mock framework.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages