7 releases

0.1.6 Jan 27, 2021
0.1.5 Jan 27, 2021

#206 in Testing

Download history 8/week @ 2021-06-28 8/week @ 2021-07-05 8/week @ 2021-07-12 21/week @ 2021-07-19 16/week @ 2021-07-26 23/week @ 2021-08-02 10/week @ 2021-08-09 18/week @ 2021-08-16 9/week @ 2021-08-23 4/week @ 2021-09-06 6/week @ 2021-09-13 4/week @ 2021-09-20 7/week @ 2021-09-27 4/week @ 2021-10-04 12/week @ 2021-10-11

73 downloads per month
Used in 4 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–1.9MB
~33K SLoC