A Philosophy of Testing 5: The Case for 100%

What is “Coverage”?

lazy val rootProject = (project in file("."))
.settings(coverageMinimumStmtTotal := 100.0)
.settings(coverageFailOnMinimum := true)

Why 100%?

“100%” Doesn’t Really Mean 100%

if (thingAreGoingAsExpected) {
doTheHappyPath()
} else {
// I believe this code path is impossible to hit,
// because...
// $COVERAGE-OFF$
reportAnError()
// $COVERAGE-ON$
}

When and How to Exempt Code

Untestable Scala

final val myConstant = "Hello world"
if (thingAreGoingAsExpected) {
doTheHappyPath()
} else {
// I believe this code path is impossible to hit,
// because...
// $COVERAGE-OFF$
reportAnError()
// $COVERAGE-ON$
}

Not Tested Yet

if (thingAreGoingAsExpected) {
doTheHappyPath()
} else {
// TODO (FOO-123): come back and test this
// $COVERAGE-OFF$
reportAnError()
// $COVERAGE-ON$
}

100% Isn’t Enough

Death to Dead Code!

Getting There From Here

Summary

Lifelong programmer and software architect, specializing in online social tools and (nowadays) Scala. Architect of Querki (“leading the small data revolution”).

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Genius of Simplicity: Mobile Jazz and Code North

WalletConnect Beta is over!

Blood Donation Management System-Summer Internship

Configuration of Apache Web Server in Docker Container using Ansible.

Interviewmania for real

How to use R scripts with Quarkus | Quarkify

THM-linux:localEnum Walkthrough

AWS — CodeBuild(下)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mark "Justin" Waks

Mark "Justin" Waks

Lifelong programmer and software architect, specializing in online social tools and (nowadays) Scala. Architect of Querki (“leading the small data revolution”).

More from Medium

A Philosophy of Testing 8: Summary

[Scala] Implicit Parameters

Scala: for-comprehension stops at the empty box

LeetCode Problem#1089 Duplicate Zeros