rea-rs-test

Makes testing of REAPER extension plugins easy.

This integration test suite was originally written by Benjamin Klum benjamin.klum@helgoboss.org for reaper-rs. But it was dependent on the reaper-high crate, which was not and would not be soon published. And, also, it was deeply integrated into the library.

This version incapsulates as much as possible, leaving simple interface to making tests.

For testing reaper extension, which itself is of type cdylib, you need transform the project folder to workspace. So, basically, project tree would look similar to this:

bash workspace_directory ├── Cargo.toml ├── README.md ├—— my_lib ├ ├—— src │ └── lib.rs └── test ├── Cargo.toml ├── src │ └── lib.rs └── tests └── integration_test.rs

test crate will not be delivered to the end-user, but will be used for testing your library. Since there is a need for patching of reaper-low and reaper-medium, contents of test/Cargo.toml:

```toml [package] edition = "2021" name = "reaper-test-extension-plugin" publish = false version = "0.1.0"

[dependencies] rea-rs = "0.1.1" rea-rs-macros = "0.1.0" rea-rs-test = "0.1.0" mylib = {path = "../mylib"}

[lib] crate-type = ["cdylib"] name = "reapertestextension_plugin"

```

contents of test/tests/integration_test.rs:

```rust use rearstest::{runintegrationtest, ReaperVersion};

[test]

fn main() { runintegrationtest(ReaperVersion::latest()); } ```

test/src/lib.rs is the file your integration tests are placed in.

```rust use rearsmacros::reaperextensionplugin; use rearstest::*; use rears::{Reaper; PluginContext}; use std::error::Error; fn helloworld(reaper: &mut Reaper) -> TestStepResult { reaper.showconsolemsg("Hello world!"); Ok(()) }

[reaperextensionplugin]

fn testextension(context: PluginContext) -> Result<(), Box> { // setup test global environment let test = ReaperTest::setup(context, "testaction"); // Push single test step. test.pushteststep(TestStep::new("Hello World!", hello_world)); Ok(()) } ```

to run integration tests, go to the test folder and type: cargo build --workspace; cargo test

Hint

Use crates log and env_logger for printing to stdio. integration test turns env logger on by itself.