O'Reilly logo

Mastering Rust by Vesa Kaihlavirta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Integration or black box tests

The test/directory contains all the integration tests. These are tests that combine the usage of several larger pieces of code together. These tests are compiled as if they were separate crates. Crate is Rust's naming for external libraries, and the whole module system will be covered in the next chapter. The only thing we care about right now is that for an integration test, we need to specify all the crates we are using, even our program's own crate (which is sum in the next example).

In this example, I have created a project, sum, with the same contents in the library as in the previous unit test, and added this integration test:

sum-with-doctest/tests/sum.rsextern crate sum; #[test] fn test_sum_integration() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required