7 releases

0.1.6 Jan 27, 2021
0.1.5 Jan 27, 2021

#709 in Testing

27 downloads per month
Used in 5 crates

Apache-2.0

6KB

cross-test

Run Rust native and web tests with a single framework.

Platforms

  • Web: web-sys
  • Native: tokio

Example

use cross_test::prelude::*;

cross_test_configure!();

#[cross_test]
async fn it_works() {
   assert_eq!(2 + 2, 4);
}

Important issue

Because #[cross_test] gets translated to #[tokio::test] all the tests must be async.

A custom proc-macro will be provided to select the test executor if the async work is present or not.

Link for the issue: https://github.com/notdanilo/cross-test/issues/1


lib.rs:

cross-test

Run Rust native and web tests with a single framework.

Platforms

  • Web: web-sys
  • Native: tokio

Requirements

To run the wasm-bindgen-tests, you need to have the nightly toolchain installed (there is no need to make it default).

You will also need to manually include wasm-bindgen-test as a dev dependency in your project because #[wasm_bindgen_test] macro can't be re-exported to avoid this requirement because of how it was designed.

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-test = "0.3.20"

Usage

use cross_test::prelude::*;

cross_test_configure!();

#[cross_test]
async fn it_works() {
   assert_eq!(2 + 2, 4);
}

Important issue

Because #[cross_test] gets translated to #[tokio::test] all the tests must be async.

A custom proc-macro will be provided to select the test executor if the async work is present or not.

Dependencies

~0–7.5MB
~47K SLoC