HTTPSimulator – Simulating HTTP Requests for unit testing made easier

 

Phill Haack just released HTTPSimulator – a class to help with running tests against a simulated Http Context, to help simulate requests and more without resorting to needing a web server running for the tests. [via DNK]

I like this approach but I also like Phil’s comments at the end. Read them. He’s right.

Also noted:

“originally tried to do all this by using the public APIs. Unfortunately, so many classes are internal or sealed that I had to get my hands dirty and resort to using reflection. Doing so freed me up to finally get certain features working that I could not before.”

This again goes to the Testable Object Oriented Design (TOOD) idea that I wrote about. Testable design might mean two categories:

  • A Test Enableing\Disabling design (Sealed classes, high coupling etc. is preventing us from writing tests that simulate or stub out parts of the design)
  • A testable\non testable design – meaning you can easily or not easily test the parts in the code you’d like to test.

In this case the HTTP related classes are test-disablers in that we cannot easily stub out their features to test something that relies on them.

HTTPSimulator – Simulating HTTP Requests for unit testing made easier

Advertisements
Explore posts in the same categories: Testing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: