Category · 50 posts
Testing Guidelines
2009
-
Test driven design – Willed vs. Forced Designs
I’m writing this as a typemock employee, but also as someone who has sat on the other side of the line for several good years, and can argue in both ways. The following, I feel, is true no matter where I work. There are…
-
Test Review: MEF
it’s late at night, and my new baby just went to sleep, again. Time for another test review! (you can find other test reviews here ) Video unavailable (the original video has been removed from Vimeo). Test Review - MEF…
-
Test Review #3 – Unity
Watch previous videos: Test Review #1 – NerdDinner Test Review #2 – ASP.NET MVC //TestReviewUnity.mp4 In this video I go over the tests for Microsoft Unity Application Block. Overall the quality of the tests in Unity is…
-
Test Review #2 – ASP.NET MVC Unit Tests
See other reviews: Review #1: NerdDinner Here’s the second video review of Unit Tests. This is another one written by Microsoft – ASP.NET MVC ( source ). First, it’s important to state how surprised I was by the high…
2008
-
Unit Testing Denial Pattern #1: Pretending the test is no longer valid
Today was both a good day for e and a bad day for me. Good day because I managed to get a full suite of tests that were somehow failing to work again after a refactoring that got out of hand. Bad - because out of all…
-
Pros and Cons and of using an Auto Mocking container in your tests
In regards to my post about injecting mocks and stubs using a container in your tests, Dave asks in the comments: Why would you want to do this in the first place? Here are the things I can think about right now (pros…
-
Testing XML serialization attributes
Not sure how I feel about this particular brand of testing syntax . still, it's good that someone thought this problem through - testing xml serialization attributes. [via the morning brew ]
-
Injecting Typemock Stubs and Mocks using the StructureMap container in a unit test
Someone asked for examples of how you'd inject stubs and mocks when you'd like your object under test to use a container such as StructureMap . here are a couple of simple tests to show this using Typemock Isolator .…
-
Creating a AutoMockingContainer with Microsoft Unity - Pretty darn simple.
updated : made container more readable Just created a little Auto Mocking Container built on Microsoft Unity. It was very very simple. here's a test that uses it. We tell the container to Returna stub for T because we…
-
Testing ASP.NET MVC Controllers with Typemock Isolator
Scott Hanselman posted his notes and slides (and movies!) from his talk on the ASP.NET MVC framework, where he also mentioned and shows how he's write unit tests for the MVC framework in ASP.NET. Scott has examples both…
2007
-
Basic Guidelines for using RowTest and data driven tests
I took a look at the code that was used to create the NUnit RowTest Extension (which is pretty neat) and found this in one of the samples: The highlighted areas in the code show something which I feel is problematic and…
-
Data Layer Testing: Test Inheritance Patterns
I'm preparing for my tutorial on Database and Data Layer unit testing that I will be giving at the Agile Practices Conference next week. It's always nice to have a full 3 hours to get pretty deep into something. 75…
-
Mocking LINQ Queries, Extension methods and Anonymous Types
One of the things I wanted to show at my Interactive session on unit testing tips and tricks at TechEd this year was how you can "Stub" out results from LINQ Queries, or mock\stub Extension methods in .NET 3.5 ( what's…
-
The various meanings of TDD
Update : more on this here and here , and Jim has a whole article on this here . Now that I'm having some real time to write something I thought I'd try to write down my thoughts starting all the way back from JAOO and…
-
The Art Of Unit Testing - Available to Purchase Online Now
I'm happy to announce that you can now purchase my book The Art Of Unit Testing through the Manning Early Access Program. Currently, the first five chapters are available, but when you purchase the MEAP version you get…
-
Code-Reuse in unit tests is more important than you think
Scott Bellware mentions how he really likes the new ideas in XUnit.NET , especially the lack of [Setup] and [TearDown] methods. (Brad Wilson wrote in the comments to my post about XUnit.NET that you can mimic this…
-
XUnit.NET aims to be the Next NUnit, but it's too soon
Update 1 : Brad answers some of my concerns on his blog. Too bad you can't write comments on his posts... Another update : There's a syntax comparison matrix between NUnit, XUnit and MbUnit. James Newkirk , one of the…
-
TDD Pattern: Composite Logic Development and Testing
Here's a video I made that captures my current thoughts on writing complex business rules which have lots of validation logic. Here's the scenario I show in the video: A Validate method on an object actually uses lots…
-
Mocks and Stubs - The difference is in the flow of information
In class today when explaining the difference between stubs and mocks, I realized a simple explanation to this: Stubs and mocks may seem the same but the flow of information from each is very different. Stubs provide…
-
Implementing Unit Test MetaData using XtUnit custom attributes
Regarding my last post on xml comments used inside a unit test Here's how you can implement the same "metadata on a test" equivalent using XtUnit custom attributes (note that you need to inhering from a custom class for…
-
Test Reviews Vs. Code Reviews - Some Helpful Tips
One of the things that I like to show people during my TDD courses, is how much easier it is to do a test review rather than a simple code review. A code review is like literally debugging the code with your eyes,…
-
FxCop is heading in the wrong direction - No testability whatsoever
If you don't know what FxCop is, go look . You'll like it. In response to my release of FxCopUnit which allows an easier experience testing out FxCop custom rules, David Kean of the FxCop blog posted his thoughts on the…
-
Introducing FxCopUnit - A framework for integrated FxCop rule testing
This post is a continuation of my Quest to test FxCop rules. The previous one was about writing pure unit tests for FxCop rules . This one is about writing Integration tests with a new framework I’ve developed called…
-
Writing real unit tests for your custom FxCop rules
Update : You might also be interested in FxCopUnit for FxCop Integration testing. It’s possible to create elegant small tests which require little to no configuration whatsoever that test out your custom rule’s ability…
2006
-
Unit Testing your ASP.NET Validators - Validation Everywhere
heynemann just posted about a very nice and testable validation framework for ASP.NET called " Validation Everywhere ". "The Validation Everywhere project was born because I have a very complex UI that I need to unit…
-
MassDataHandler: generate test data to help with data layer testing
Yet another tool to help with integration tests against the database layer(got this by email: "I wanted to let you know about an open source tool I created to help unit test the data access layer.…
-
DataFresh - Database rollback library for unit tests
A while ago I wrote an article about database unit testing , and the various ways you could "rollback" the database state to the way it was before the test ran. Today I got an interesting comment from Mike Brockey : "I…
-
The Art Of Unit Testing - Download Chapter 1
I'm happy to announce that draft of chapter 1 from my upcoming book " The Art of Unit Testing " is available for download immediately - click here for the PDF . the book will also be available to download from Manning's…
-
Avoid multiple asserts in a single unit test: revisited
James Avery argues that what he'd really like to see in a unit test framework is the ability to run (and fail) multiple asserts within the same test. As some background, I personally am in favor of the " single assert…
-
Simple designs through Test Driven Development
Scott Bellware keeps on wowing me with his elegant way of putting ideas into words, sentences and paragraphs. If you are into Test Driven Development, you should be reading his blog . In one of his latest posts he talks…
-
Jeremy Miller: Best and Worst Practices for Mock Objects
Jeremy Miller writes some of his recommendations for best and worst practices for using Mock Objects in your Unit Tests. He makes a lot of sense and I wholeheartedly agree with his conclusions. His writing is clear and…
2005
-
[Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears
My latest MSDN Magazine article titled " Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears " is out in the online January Issue here. It's based on real issues, guidelines I've…
-
[Article] Issues in breaking dependencies for unit testing
One of the most important issues I've come to realize is the various ways of dealing with legacy code, mainly - how to deal with breaking multiple dependencies on an existing class or method that needs to be tested.…
-
Unit test readability should not come in place of maintainability - they go hand in hand
Brian Button writes this post about a best practice he believes in when writing unit tests. The main idea in that post is that when you use Setup and TearDown methods in your tests, you're essentially separating parts…
-
[Article] The Test Feasibility Matrix
One of the toughest questions in projects that contain legacy code that would like to write unit tests from part of that code (it may need to change) are: "Where should I start?" When one of my clients faced this…
-
Performance vs. Testability and semi-virtual method calls
I won't try to sit here and say that the issue of performance vs. testability can be summed up in one blog post (or a full article for that matter). However, it's an important one and during my consulting gigs I've come…
-
The Mock Objects elevator speech
A friend asked me by email the other day :"So why do I need mock objects?" I came up with this in roughly 3 minutes so it's a bit rough, but it'll do to drive the point home, I hope. Note, that this does not really…
-
Use Mock Logs instead of expectations when it makes sense
Len Holgate writes about a little known technique for using Mock Object testing which is very applicable in languages like C++ where Mock Object frameworks are hard to use and mocks are hard to create anyway. Instead of…
-
Try to avoid multiple asserts in a single unit test
Consider Assert failures as symptoms of a disease and Asserts as indication points or blood checks for the body of the software. The more symptoms you can find, the easier the disease will be to figure out and remove.…
-
Another Entlib example: Separate integration tests from unit tests (and learn to know the difference)
Here are some more inputs on the EntLib unit tests runnability issues ( problems as specified in this blog post ) [I've bolded some phrases I thought were important in the original text] : Data 56 tests will fail if you…
-
Test maintainability: consider creating a test fixture "per method" instead of "per class"
If you find yourself writing lots of tests for a single method on your tested class - consider making a specific fixture for just one method or feature. It would make the class more maintainable and logically sound. For…
-
Enterprise library -- Test usability and "runnability"
So, Enterprise Library is out and it's a great thing. It even has unit tests. But is anyone actually using them? Enterprise Library is a great test case for the issue of unit tests usability because: It will be used by…
-
Making your tests withstand design and interface changes - remove code duplication
One of the biggest pitfalls developers writing unit tests face is in the face of a re-design. They write hundreds of unit tests for various classes, and suddenly a design change breaks many of them - a default…
-
What should you write in a test Assert message?
The Assert message in a test is one of the most important parts. It's there to tell us what went wrong with our code. what we expected to happen but didn't, and what should have happened instead. A good assert message…
-
What Algorithms should you test and how?
[ Update : I've updated the description here to make it clearer. Some of the comments indicate that I did not explain myself as well as I should have. Perhaps this is better.] Math Algorithms are problematic. The…
-
Tests should reflect required reality
One of the most common mistakes of newcomers into TDD is that they often mistake the “Fail first” requirement with “Fail by testing something illogical”. For example, given a method requirement with this spec: Int…
-
When should you remove or change a unit test?
As a rule, a passing test should never be removed. That's because passing tests serve as the regression tests for our maintenance work. They are there to make sure that when we change code we don t break anything else…
-
Test Coverage and testing angles
How do you know if you have good coverage on your new code? Try and remove a line or a constraint check . If all tests still pass – you don't have enough code coverage and you probably need to add another unit test. The…
-
A Unit test should test only one thing
This guideline is much more aggressive and recommended if you work in a test driven manner rather than write the tests after the code has been written. The main goal here is better code coverage or test coverage. Here s…
-
Naming standards for unit tests
The basic naming of a test comprises of three main parts: [UnitOfWork_StateUnderTest_ExpectedBehavior] A unit of work is a use case in the system that startes with a public method and ends up with one of three types of…