You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some practical reasons and constraints for some of this:
Tests are not run in the embedded playgrounds — the playgrounds need a main function.
On the other hand, we run tests via cargo test in CI!
So I like tests because they help keep the course code correct. I also think it's fine to show people simple unit tests from day 1: they're just small functions after all and don't look scary in my opnion.
We ask people to solve most or all exercises in https://play.rust-lang.org/ or locally using an editor with rust-analyzer. This means that they can execute tests just fine. However, having passing tests be the criteria for success takes away some of the free-form experimentation that you can do when you just have some code and a main function to call it from.
Related to this, it always bothered me how Rust doctests have to use assert_eq!(foo, 123) to express the expectations in your example. It feels dry and it means I cannot talk about things like println! or dbg! output in my example. I like the Python way much more where you show an interactive console session.
However, since we're not Python and don't have such interactive tools, I guess using small unit tests is okay. A bit boring, but probably also more professional 😄
See #1565 for context.
Also, put all text above the code sample!
The text was updated successfully, but these errors were encountered: