You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-12-23 06:56:25 +02:00
Move Mockall and GoogleTest slides to Android section (#1533)
After #1528 and #1532, we now have actual slides which showcase the crates in action. So we can reclaim a few minutes by removing the slide which mentions Mockall and GoogleTest slide. The slide mentioned [proptest](https://docs.rs/proptest) and [rstest](https://docs.rs/rstest) as well. While I'm sure the libraries are useful, we don't have them imported into AOSP and I've never personally used them. We should therefore not advertise them yet at this point since they won't be useful to Android engineers. Of course we can mention things that are not in AOSP (or in Chromium), but I think we should do it in the speaker notes at most.
This commit is contained in:
37
src/android/testing.md
Normal file
37
src/android/testing.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Testing in Android
|
||||
|
||||
Building on [Testing](../testing.md), we will now look at how unit tests work in
|
||||
AOSP. Use the `rust_test` module for your unit tests:
|
||||
|
||||
_testing/Android.bp_:
|
||||
|
||||
```javascript
|
||||
{{#include testing/Android.bp}}
|
||||
```
|
||||
|
||||
_testing/src/lib.rs_:
|
||||
|
||||
```rust
|
||||
{{#include testing/src/lib.rs:leftpad}}
|
||||
```
|
||||
|
||||
You can now run the test with
|
||||
|
||||
```shell
|
||||
{{#include build_all.sh:libleftpad_test}}
|
||||
```
|
||||
|
||||
The output looks like this:
|
||||
|
||||
```text
|
||||
INFO: Elapsed time: 2.666s, Critical Path: 2.40s
|
||||
INFO: 3 processes: 2 internal, 1 linux-sandbox.
|
||||
INFO: Build completed successfully, 3 total actions
|
||||
//comprehensive-rust-android/testing:libleftpad_test_host PASSED in 2.3s
|
||||
PASSED libleftpad_test.tests::long_string (0.0s)
|
||||
PASSED libleftpad_test.tests::short_string (0.0s)
|
||||
Test cases: finished with 2 passing and 0 failing out of 2 test cases
|
||||
```
|
||||
|
||||
Notice how you only mention the root of the library crate. Tests are found
|
||||
recursively in nested modules.
|
||||
Reference in New Issue
Block a user