Hopefully you have a culture of testability ingrained within your development team. In my experience, good developers write unit tests, and the best developers estimate their work to include unit tests.
Elegant: Elegant code is another word for simple code. Unfortunately, many developers (including myself) thrive in the complex.
Writing simple code is hard. You need to resist the urge to write code and take a step back. Some of the best code I have ever written has very few lines, and that is because I took my time and thought about what I needed to do. In the end, I wrote less code than I originally thought I needed.
There is no tool that helps you write elegant code. Being able to write elegant code comes with experience. The one piece of advice that I give developers is “Always be learning.” In our industry, there is always some new better way of doing something you previously have done.
Beyond unit tests
Having unit tests that meet an acceptable minimum for code coverage is a great start. There are other types of tests that can help improve the quality of your code. Functional, load, stress and performance tests are but a few types of tests you can do to improve quality. Often you need dedicated infrastructure to support such tests, which also require more effort in terms of time of and skill.
Functional testing is a significant step above unit tests. The goal of a functional test is to test the features of the application. Some example of tools that support functional testing are Coded UI and Web tests in Visual Studio. Web tests help you exercise your Web pages and services.
A practice known as behavior-driven development is related to functional testing and test-driven development in that specialized tools are used during the software process to help test the requirements of the application. Examples of tools that support this type of testing are SpecFlow (Cucumber for .NET) and NBehave. These tools are great if you have a large set of functional use cases that need to be tested. I had the opportunity to work with a development team that used SpecFlow. They had more than 15,000 tests that tested the functionality of the application each night.
Load testing tests the throughput of your application. Often the goal is to measure how many users an application can support. This starts by creating a test script that performs the actions that a user would perform. Instances of the test script are created until the application hits a maximum number of simultaneous users, or until the service-level agreements are no longer met.
Visual Studio has had the ability to create and run load tests for years now. Recently this capability was extended to take advantage of Visual Studio Online (formerly Team Foundation Service), which allows you to run your load tests in the cloud. This is great way to do load testing without setting up a dedicated infrastructure, and it clearly demonstrates the benefits of cloud-based infrastructure.