FIR[S]T: [S]elf-Validating
“I’ve been writing tests for years,” says Pat. “Every once in a while, I write a main() method that drives some of my code. It spews a bunch of output onto the console using System.out.println(). I take a look at each result and compare it with what I expect the right answer to be.”
“That’s great,” says Dale, “Most of us have done that sometime in our career, but it doesn’t hold up so well to larger numbers of tests. I remember having to add lots of comments in main() to explain what I was testing next.”
“I split them into smaller methods when they get out of hand,” says Pat.
“Hmm…,” says Dale, sporting a bemused look. “I also recall having a problem remembering what the expected output should look like. Sometimes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access