Skip to main content

Command Palette

Search for a command to run...

Structuring Effective Unit Tests

Updated
โ€ข1 min read
Structuring Effective Unit Tests

Mentoring

"Maximizing Test Coverage and Efficiency: A guide to structuring Unit Tests"

๐‘จ๐‘จ๐‘จ ๐’‘๐’‚๐’•๐’•๐’†๐’“๐’ - ( ๐˜ข๐˜ณ๐˜ณ๐˜ข๐˜ฏ๐˜จ๐˜ฆ, ๐˜ข๐˜ค๐˜ต, ๐˜ข๐˜ด๐˜ด๐˜ฆ๐˜ณ๐˜ต)

๐†๐ข๐ฏ๐ž๐ง-๐–๐ก๐ž๐ง-๐“๐ก๐ž๐ง- very similar to 3A

In the ๐’‚๐’“๐’“๐’‚๐’๐’ˆ๐’† section you bring the SUT and its dependencies to a desired state.

In the ๐’‚๐’„๐’• section, you call the methods on SUT, pass the prepared dependencies, and capture the output value ( if any )

In the ๐’‚๐’”๐’”๐’†๐’“๐’• section, you verify the outcome.

๐†๐ข๐ฏ๐ž๐ง corresponds to arrange

๐–๐ก๐ž๐ง corresponds to act

๐“๐ก๐ž๐ง corresponds to assert

There's no difference between these two patterns, it's just that the Given-When-Then pattern is more readable to non-programmers.

More from this blog

A

Adrian Kodja some Insights and Innovations: Exploring the World of a Seasoned Software Engineer

35 posts

I am a software craftsman with a passion for writing clean, efficient, and well-organized code.