Welcome to MSDN Blogs Sign in | Join | Help

Browse by Tags

All Tags » Unit Testing   (RSS)

testmethod Code Snippet

This is an installment in my Zero-Friction TDD series. If you are a regular reader of this blog, you may have noticed a certain pattern in my unit test examples (like this one ). This is because I always follow the Four-Phase Test pattern (which is a
Posted by ploeh | 1 Comments
Attachment(s): testmethod.snippet

Ignore Irrelevant Return Values

This is an installment in my Zero-Friction TDD series. Sometimes, you don't care about the return value from a particular operation. The simplest example is if you want to check that creating a new instance of a specific type will throw an exception if
Posted by ploeh | 1 Comments

Anonymous Variables

This post is an installment in my series on Zero-Friction TDD . Often when writing a unit test, the SUT 's API will force you to create objects that you really don't care about. As an example, take a look at the signature of this constructor: public Plop(
Posted by ploeh | 2 Comments

Naming Direct Output Variables

In my series of Zero-Friction TDD tips and tricks, it's time to look at naming Direct Output variables. [ TestMethod ] public void DoStuffWillReturnMessage() {     // Fixture setup     string expectedResult = "ploeh"
Posted by ploeh | 1 Comments

Zero-Friction TDD

Writing good code is difficult. Unit tests are written as code, so a corollary to the first sentence is that writing good unit tests is also difficult. TDD (particularly if you interpret the last D as Design ) carries this challenge in abundance, since
Posted by ploeh | 3 Comments

Assert.Throws

xUnit.net provides the Assert.Throws method for testing exceptions, instead of the ExpectedException attribute. In his original announcement , James Newkirk explains why this is a much better approach, and I can only agree. However, those of us that for
Posted by ploeh | 4 Comments
Filed under:

Naming SUT Test Variables

If you are a regular reader of this blog, you may have noticed that for the last couple of months, every test I've posted has shared some similarities; one of which is that I always name my SUT test variable sut . Here's a simple example: [ TestMethod
Posted by ploeh | 5 Comments
Filed under:

Testing Against the Real Event Log

Lots of applications write to the Windows Event Log. When TDD'ing, event logging is part of an application's Indirect Output , so to verify that logging happens correctly, you need to verify the test against an Observation Point . As always, the correct
Posted by ploeh | 6 Comments
Filed under:

SqlExpressDatabaseInstaller

When unit testing data access components, I prefer to test against run-time components that match the target environment as closely as possible. In other words, if the data access component targets SQL Server 2008, I prefer to test against a SQL Server

An Overview of Unit Testing Duplex WCF Services and Clients

In the last couple of posts, I've demonstrated how to isolate implementation from WCF contract definition and behavior in a duplex communication scenario. These posts have been rather detailed, so it occurred to me that you might benefit from an overview.

Unit Testing Duplex WCF Clients

In my previous post , I explained how to unit test a WCF service with callbacks. Since the scenario involves duplex communication, the service is also a client, and vice versa, so it's only reasonable to look at the 'client' as well, to examine how to

Unit Testing Duplex WCF Services

One of my readers recently asked me about unit testing WCF services when they have callbacks. Given that I strongly believe that you should attempt to implement your services without referencing WCF at all , but duplex WCF services require you to get
Posted by ploeh | 5 Comments
Filed under: ,

Implementing WCF Services Without Referencing WCF

More than a year ago, I wrote my first post on unit testing WCF services . One of my points back then was that you have to be careful that the service implementation doesn't use any of the services provided by the WCF runtime environment (if you want
Posted by ploeh | 4 Comments
Filed under: ,

Test-Specific APIs With Extension Methods

Writing maintainable tests that clearly communicate intent can sometimes be a challenging undertaking. Ideally, a unit test suite should act as executable documentation and be robust when faced with refactoring of the SUT . Some software lends itself
Posted by ploeh | 0 Comments
Filed under:

Unit Testing Anti-Pattern #2: Not Covering Bugs In Your Tests With Tests

Roy just posted a unit testing anti-pattern based on his personal experience. I'd like to follow up with one from my own personal experience: A few days ago, while working with one of our unit test suites, I discovered that one of my test utility classes
Posted by ploeh | 0 Comments
Filed under:
More Posts Next page »
 
Page view tracker