Monday, December 7, 2015

C# Web Project Testing and Debug Techniques

Several options are available for software testing and debug, but here we'll focus on unit testing with Visual Studio, integration testing with SoapUI and Selenium WebDriver, and debugging with Visual Studio and web browser developer tools.

Why Test?
Before I get started, the reason developers care about testing is because it helps minimize software defects throughout the entire software development life-cycle.  A couple things to note, however, is that software testing does not solve all our problems:  
  • Testing adds time to the development timeline because things like unit and integration tests don't write themselves, and
  • Tests will find the bugs in the tested conditions--but defects may still exist in promoted software.
Despite the caveats, software development should include testing to ensure the highest quality of code from start all the way through to future maintenance.  Software projects should start with clear goals for testing to ensure adequate test coverage within the project budget and timeline.

Types of Testing
Unit Test
Unit tests are software written to evaluate a given condition against the result of executing code to ensure a consistent and predictable outcome.  Unit tests are written to test the lowest level of functionality within a program.  As the word unit suggests, the test condition should focus on a small chunk of code that does a very specific task such as adding two numbers.  Shashank Tiwari wrote an article, Software Testing Types you Should Know About, that does a good job introducing the major types of testing.  Below is his illustration of how a unit test works.
Tiwari's logic diagram of how a unit test works
Integration Test
Integration tests are software written to evaluate a given condition against the expected result of multiple software components working together to form a single response.  As an example, an integration test may be written to check an employee web service method returns a specific employee name based on a given employee ID.  The illustration below describes how the integration test would look in this scenario.
Integration test example where the name John Doe is expected given an employee ID of 1

Test Tools
Several frameworks and applications are available for testing.  Here I'll cover unit testing in Visual Studio and integration testing with SmartBear's SoapUI, Chrome's Postman, and Selenium.
Unit Testing in Visual Studio
Unit testing in Visual Studio is pretty easy and is described in this great MSDN article.  Note that you can use several unit test frameworks such as NUnit; however, Microsoft's UnitTest framework is readily available and provides everything you need to get started.

Unit tests can be developed before authoring the application code in a process described as test driven development.  In this approach, the developer begins with writing unit tests and uses Visual Studio's automation tools to build-out the application code.  In my experience, the test driven approach promotes detail in application design and an improved focus on development.  This MSDN article describes a quick start example for a test driven Visual Studio solution.

Integration Testing with Smarbear's SoapUI

Automated Testing with Selenium




5 comments:

  1. I like your post there is a lot of information about software testing companies, which I would like to learn, thank you for the great guide.

    ReplyDelete
  2. I admire your point; a full-time angular js developer’s salary is almost equal to a freelance angular js developers' pay. You just need to be a responsible employee. You will be making money pretty easily if you develop your programming skills and experience to a professional level. Eiliana can help you make good money as well as balance your professional and personal life. It is a new yet great platform for freelancers.

    ReplyDelete