Structuring Effective Unit Tests


1 min read

Table of contents

No heading

No headings in the article.


"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.