.NET Code Documentation And Testing: They Are There, Why Not Use It?

Remember the “///”?  They are the C# XML documentation comments and they are pretty useful when you are building your APIs and frameworks so other developers who use your code can at least see some useful information on your classes and methods through the intellisense provided by the Visual Studio IDE.

Take the following sample code below.  I have a constructor and a method decorated with XML comments.

And on the code where they are used, when I hover over them I will see my comments displayed.



So how about code testing?  .NET or more accurately Visual Studio comes with the Microsoft unit test framework.  It’s so easy to add one to your new project or existing project.  Once you have the stubs created for you, you can start coding your tests.

Below is a sample unit testing code I created.

So every time you make changes to your code, and I say you will always need to change or refactor code, running these tests will make sure you didn’t break anything.  So it is a pretty useful tool and I see the benefit in this.  And it’s so nice to see so many green check marks on your Test Explorer.


For more information, check out these links:

Leave a Reply

Your email address will not be published. Required fields are marked *