Elephants for breakfast
bitfieldconsulting.com·9w·
Discuss: Hacker News
Flag this post

If you have a tough question that you can’t answer, first tackle a simpler question that you can’t answer. —Max Tegmark, “Our Mathematical Universe”

Everyone knows how to eat an elephant (but please don’t: they’re quite endangered). The point is that apparently intimidating tasks can always be dealt with by breaking them up into more tractable sub-tasks, and the same applies to testing.

For example, in Here comes the sun, we did the bare minimum to create a simple weather client program in Rust, and now we’re interested in testing the get_weather function that we wrote. Here’s our first attempt at a test:

#[cfg(test)]
mod tests {
use std::env;

use super::*;

#[test]
fn get_weather_fn_re...

Similar Posts

Loading similar posts...