Skip to content

abelikt/rust_testing_frameworks

Repository files navigation

Rust testing frameworks for unit-, integration- and system-tests

... tried out.

And still under heavy but slow development.

Folders herein:

  • untested_code: A piece of untested code that should serve as template for further tests

  • mockall_mock_a_sensor: Multiple approaches with cargo test and mockall (not in sync with the template

  • {F}_experiment : Some experiments with Framework F

Run stuff in the workspace

Build everything

cargo build --all

Run all tests

cargo test --all

Run a specific test

cargo test --bin mockall_mock_a_sensor

Used / tested / tried already:

ToDo List

Create usability matrix for UT, IT, ST and general impression.

To-Do list - frameworks:

BDD

To-Do list - helpers, macros, etc

To-Do list - test doubles

Test doubles: run-time mocking

Concepts for installing runtime-mocks, that need no change of the production code. It is easy e.g. for Python to install runtime mocks to cut out dependencies e.g. with matching / monkeypatching.

For languages with static type systems, this is almost impossible without tricks and black magic. For C++ there is for example Hippomocks (https://github.com/dascandy/hippomocks). Hippomocks works by changing the op-codes to the functions in the program memory to the adress of the mock function. A very powerfull trick to my opinion and a very powerful framework.

Injectorpp seems to work similar to Hippomocks and applies dark and unsafe powers to do the trick:

https://crates.io/crates/injectorpp

https://docs.rs/injectorpp/0.4.0/injectorpp/

https://github.com/microsoft/injectorppforrust

More hints are on:

Ideas for new templates

Add a code template for a system test that calls processes; with other permissions; sudo, sudo -E; runs regex on stderr and stdout; injects stdin; calls processes in sub-shells; call system management like systemd.

Further Links

About

Rust testing frameworks for unit-, integration- and system-tests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages