Jump into Test-Driven Development

It’s taken me a while to get used to a new paradigm in development, which is commonly referred to as Test-Driven.

The main idea is to create a test for code that isn’t written yet, watch it fail, then continue coding until it works.

In Visual Studio you just need create a new test project (you can also create a Unit Test project).

Then in code create a TestClass and TestMethod’s by adding the appropriate attributes as seen below:

The code in this example came from Jonathan B’s C# group meeting lecture on Evolving your code, here’s his website:

http://www.theabsentmindedcoder.com/

Then F5 (run) and you’ll see whether your Assert statements pass.

Constant testing of new functions and classes helps weed out logical errors that can show up down the road in actual program testing or even worse, after deployment.

Advertisement
This entry was posted in C#. Bookmark the permalink.

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 )

Connecting to %s