Skip to main content

Structuring Effective Unit Tests

Updated 1 min readMarkdown
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.

About the author

  • I'm a seasoned Software Engineer with over half a decade of experience shaping the world of software development. My passion is anchored in writing code that is not just efficient, but also elegant and clean. An advocate for continuous improvement, I am forever on the hunt for the most cutting-edge developments in our dynamic industry.

No comments yet. Be the first to comment.

More from this blog