The Artima Developer Community
Sponsored Link

.NET Buzz Forum
From Fact to Theory

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Christian Horsdal

Posts: 253
Nickname: horsdal
Registered: Mar, 2009

Christian Horsdal is a software architect at MjĂžlner Informatics.
From Fact to Theory Posted: Sep 1, 2013 12:13 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Christian Horsdal.
Original Post: From Fact to Theory
Feed Title: Horsdal
Feed URL: http://www.horsdal-consult.dk/feeds/posts/default
Feed Description: A blog that will be about code, architecture, design, and .NET.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Christian Horsdal
Latest Posts From Horsdal

Advertisement
I often find that the tests I write can be slowly generalized as the feature I happen to be working on is fleshed out. In xUnit.net terms I find that a fair number of the tests tend to move through these four stages:
  1. Start out as a single [Fact], working on hardcoded input data
  2. Pull out the hardcoded data, turning the tests into a [Theory, AutoData]
  3. Add edge cases, evolving the test into [Theory, AutoData, InlineData, InlineData]
  4. Add cases representative of equivalence classes, thus adding more InlineData attributes to the test
Each of the stages generalizes the test a bit more making it more potent in several ways. As the test moves through each stage it gains greater coverage in terms of the possible inputs, making it a better regression guard. But there is more at play. Along with the generalization (and multiplication) of the inputs the test can often be refactored towards being more about the behavior of the SUT and less about its implementation. So alongside the four stages above I find tests tend to move through these stages as well:
  1. While being a [Fact] the test is named something very specific - a specific example of how the SUT should behave
  2. During stage 2 or 3 the test name becomes something that expresses a general trait of the SUT
  3. The assertions in the test becomes less dependent on implemntation details
I am not always able to make my tests follow either of these progressions, but when I am I find it very rewarding.

Read: From Fact to Theory

Topic: Conditional Lightweight Compilation in C# Previous Topic   Next Topic Topic: Introduction to Windows 8 Store Apps

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use