feat: add links about testing in Rust (#5791)

feat/mobile
Ruslan Semagin 5 months ago committed by Kamran Ahmed
parent d95c1d66f0
commit b67cb99f41
  1. 7
      src/data/roadmaps/rust/content/119-testing/100-unit-integration.md
  2. 8
      src/data/roadmaps/rust/content/119-testing/101-mocking.md
  3. 7
      src/data/roadmaps/rust/content/119-testing/index.md

@ -1,3 +1,8 @@
# Unit and Integration Testing # Unit and Integration Testing
In Rust language, the concept of unit integration encompasses writing tests for individual units of your code, typically a function or method, as well as for multiple units that interact with each other. Unit tests are written in the same files as the code and are used to verify the functionality of a single unit of software in isolation. On the other hand, integration tests are stored in an entirely different directory and are meant to test how multiple components or modules of your application work together. They rely on combining units of code and testing the group, identifying issues that may not be visible when units are tested in isolation. In Rust language, the concept of unit integration encompasses writing tests for individual units of your code, typically a function or method, as well as for multiple units that interact with each other. Unit tests are written in the same files as the code and are used to verify the functionality of a single unit of software in isolation. On the other hand, integration tests are stored in an entirely different directory and are meant to test how multiple components or modules of your application work together. They rely on combining units of code and testing the group, identifying issues that may not be visible when units are tested in isolation.
Visit the following resources to learn more:
- [Rust Book: How to Write Tests](https://doc.rust-lang.org/book/ch11-01-writing-tests.html)
- [Rust by Example: Unit testing](https://doc.rust-lang.org/rust-by-example/testing/unit_testing.html)

@ -1,3 +1,9 @@
# Mocking and Property-based Testing # Mocking and Property-based Testing
In Rust, **mocking** is a process that lets you create fake functions, objects, or behaviors to test different conditions and scenarios in your code. Rust does not natively support mocking, however, there are external libraries present to help you perform mocking. Some of the popular libraries for mocking in rust are `mockall`, `mockiato`, and `double`. These libraries give you the ability to create mock structures with the same API as your original code and allow you to set predefined responses from functions or validate function calls, thus helping you test your rust code thoroughly. In Rust, **mocking** is a process that lets you create fake functions, objects, or behaviors to test different conditions and scenarios in your code. Rust does not natively support mocking, however, there are external libraries present to help you perform mocking. Some of the popular libraries for mocking in rust are `mockito`, `mockall`, and `mockall_double`. These libraries give you the ability to create mock structures with the same API as your original code and allow you to set predefined responses from functions or validate function calls, thus helping you test your rust code thoroughly.
Visit the following resources to learn more:
- [Docs.rs: mockito](https://docs.rs/mockito/latest/mockito/)
- [Docs.rs: mockall](https://docs.rs/mockall/latest/mockall/)
- [Docs.rs: mockall_double](https://docs.rs/mockall_double/latest/mockall_double/)

@ -1,3 +1,8 @@
# Testing # Testing
"Testing" in Rust is a crucial part of any programming project. This procedure involves creating specific scenarios to determine whether your code functions as expected. Rust has built-in support for this via the `cargo test` command which will run your test functions. These test functions are typically marked with the `#[test]` attribute to signify that they are not regular functions but testing adjuncts. Rust also provides a few macros such as `assert!`, `assert_eq!`, and `assert_ne!` for comparison checks and confirming expected behavior. "Testing" in Rust is a crucial part of any programming project. This procedure involves creating specific scenarios to determine whether your code functions as expected. Rust has built-in support for this via the `cargo test` command which will run your test functions. These test functions are typically marked with the `#[test]` attribute to signify that they are not regular functions but testing adjuncts. Rust also provides a few macros such as `assert!`, `assert_eq!`, and `assert_ne!` for comparison checks and confirming expected behavior.
Visit the following resources to learn more:
- [Rust Book: Writing Automated Tests](https://doc.rust-lang.org/book/ch11-00-testing.html)
- [YouTube](https://www.youtube.com/watch?v=8XaVlL3lObQ)

Loading…
Cancel
Save