Tutorials and resources on how to apply unit testing in software testing
Rowan Miller shows how to replace a DbContext based data access layer with an in-memory fake for unit testing in this blog post. He builds an interface that represents the context and then builds an in-memory fake of that context for use in our unit tests. He uses an MVC controller but the same approach can be used with any component that needs to interact with an EF based context, including repositories. The key benefits of this approach are stable and robust tests that execute quickly and exercise a single component, making failures easy to isolate.
This blog post provides a detail process on how to create and run unit tests for Google App Engine applications. The author shows how to write the tests using the standard python unittest module and execute them with gaeunit, a web based test runner. He reminds us that it is easier to write unit tests during design rather than afterwards. We should also keep the tests high level so that further detailed modifications will not break the tests. A short video summarizing Google App Engine unit testing is available at the end.
Issues with testability in Java boil down to our inability to write tests or the excess trouble we have to go through to get it done. In this article, based on chapter 7 of the book “Effective Unit Testing – A guide for Java developers”, Lasse Koskela shares a set of dos and don’ts for testable design. In the tips provided, he recommends to avoid complex private methods, static methods, logic in constructors and to favor composition over inheritance.
Unit tests are useful and effective if you remember to make them FIRST. FIRST is an acronym for Fast, Isolated, Repeatable, Self-Verifying and Timely. Each of this points is discussed in the article with examples. The most important thing about unit tests is that they be useful and effective for your programming team. The FIRST mnemonic is a simple mechanism to guide you there.
This article provides a detailed description on how use Pex and Moles to generate unit tests for a project having external dependency(WCF Proxy) using Visual Studio 2010 SP1. The Pex tool, which automatically generates test suites with high code coverage, will be used to generate unit tests. Moles allows to replace any .NET method with a delegate. They will be generated to isolate the external dependency (WCF proxy) and behavior will be redefined using delegates.
This article presents a simple and efficient engine which produces mutations of source code written in C# with helps testing it. The novelty of this engine is that it produces mutations that do not contradict with the specifications of the program. The latter are described by a set of pre- and post-conditions and invariants. The engine comprises two parts, a static analysis and syntactic verification component and a mutation generation component. Preliminary experiments showed that the proposed engine is more efficient than a simple mutations generator in terms of producing only valid mutations according to the specifications posed, thus saving time and effort during testing activities.
This article presents a strategy for unit testing in Python, using a set of utility functions that converts to and from Roman numerals. The author discusses the benefits of a Test-Driven Development (TDD) approach and propose a detailed testing process for all the cases of the functions.