rustlings icon indicating copy to clipboard operation
rustlings copied to clipboard

Tests tasks 1 & 2 are redundant

Open poneciak57 opened this issue 2 years ago • 2 comments

These two tasks do not teach anything they just show two methods without any example if someone have no idea about what testing is he will not understand the point of doing this. I would consider deleting them or merging them with tests/tests3.rs into one big task that shows all the simple methods on real life example

tests/tests1.rs:

#[cfg(test)]
mod tests {
    #[test]
    fn you_can_assert() {
        assert!();
    }
}

tests/tests2.rs:

#[cfg(test)]
mod tests {
    #[test]
    fn you_can_assert_eq() {
        assert_eq!();
    }
}

poneciak57 avatar Apr 05 '23 06:04 poneciak57

I agree that those examples could be spruced up with some additional logic, but I don't think merging them is a good idea. If you want to take a stab at adding a bit more substance to them, though, feel free to open a pull request!

manyinsects avatar Apr 05 '23 09:04 manyinsects

If you check tests/tests3.rs it is like tests1.rs with some additional logic, so my proposition is to delete tasks 1&2 and extend the task 3 a little bit or delete task 1 and extend task 2 with some logic or story behind

tests/tests3.rs:

pub fn is_even(num: i32) -> bool {
    num % 2 == 0
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn is_true_when_even() {
        assert!();
    }

    #[test]
    fn is_false_when_odd() {
        assert!();
    }
}

tests/tests1.rs:

#[cfg(test)]
mod tests {
    #[test]
    fn you_can_assert() {
        assert!();
    }
}

poneciak57 avatar Apr 05 '23 14:04 poneciak57

I improved tests1 and tests2 and removed tests3 in the upcoming version 6: https://github.com/rust-lang/rustlings/tree/v6/exercises/17_tests

mo8it avatar Jun 27 '24 15:06 mo8it