DEV Community

loading...

Discussion on: A Different Unit Test Pattern

Collapse
eljayadobe profile image
Eljay-Adobe • Edited

When I was doing C# programming (using the TDD process, NUnit and NCrunch), our unit tests followed the WET principle.

"Write Explicit Tests", which meant the unit tests should test one-and-only-one thing, should not have branches or loops, and do not have a communal set-up and tear-down code. Each unit test is responsible for the entirety of its Arrange-Act-Assert sections.

DRY is great for the code under test, but not for unit tests themselves. WET is much better.

My former co-worker Arlo Belshee wrote up a nice blog post about DRY & WET: arlobelshee.com/wet-when-dry-doesn...

Collapse
rfornal profile image
bob.js Author

Exactly ... the code I presented abstracted put the Arrange and Act portions of the tests. I strongly suspect this was to adhere to the single Assert so tightly, they lost focus on what actually needed to be accomplished ... adjusting the code-under-test to make it more testable.

Collapse
rfornal profile image
bob.js Author

I should also mention that I read the article you included ... great stuff: arlobelshee.com/wet-when-dry-doesn...