Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
What is the purpose of grouping the tests in a tests module like this #[cfg(test)] mod tests { use super::*; #[test] fn test_function_1() { // test code for function 1 g...
#4: Post edited
- What is the purpose of grouping the tests in a `tests` module like this
- ```
- #[cfg(test)]
- mod tests {
- use super::*;
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- }
- ```
- and is it possible to split them and have the test functions outside of the `tests` module?
- ```
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
```
- What is the purpose of grouping the tests in a `tests` module like this
- ```
- #[cfg(test)]
- mod tests {
- use super::*;
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- }
- ```
- and is it possible to split them and have the test functions outside of the `tests` module?
- ```
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- ```
- I don't want to split them into their own directory.
#3: Post edited
- What is the purpose of grouping the tests in a `tests` module like this
- ```
- #[cfg(test)]
- mod tests {
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- }
- ```
- and is it possible to split them and have the test functions outside of the `tests` module?
- ```
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- ```
- What is the purpose of grouping the tests in a `tests` module like this
- ```
- #[cfg(test)]
- mod tests {
- use super::*;
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- }
- ```
- and is it possible to split them and have the test functions outside of the `tests` module?
- ```
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- ```
#2: Post edited
- What is the purpose of grouping the tests in a `tests` module like this
- ```
- mod tests {
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- }
- ```
- and is it possible to split them and have the test functions outside of the `tests` module?
- ```
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- ```
- What is the purpose of grouping the tests in a `tests` module like this
- ```
- #[cfg(test)]
- mod tests {
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- }
- ```
- and is it possible to split them and have the test functions outside of the `tests` module?
- ```
- #[test]
- fn test_function_1() {
- // test code for function 1 goes here
- }
- #[test]
- fn test_function_2() {
- // test code for function 2 goes here
- }
- ```
#1: Initial revision
What is the purpose of grouping the tests in a `tests` module and is it possible to split them?
What is the purpose of grouping the tests in a `tests` module like this ``` mod tests { #[test] fn test_function_1() { // test code for function 1 goes here } #[test] fn test_function_2() { // test code for function 2 goes here } } ``` and is it possible to split them and have the test functions outside of the `tests` module? ``` #[test] fn test_function_1() { // test code for function 1 goes here } #[test] fn test_function_2() { // test code for function 2 goes here } ```