Tutorials and resources on how to apply unit testing in software testing
Any developer who cares about software quality should be committed to writing unit tests. Used well it can be a vital tool in every developer’s toolbox, but unfortunately the theory and practice don’t always match up. Easily-made mistakes can lead to brittle, unmaintainable and ‘write-only’ tests that not only become difficult to work on, but can lead to a hatred of unit testing in general. Presented here are examples of these mistakes with code samples, why you’re making them and how to avoid them in future.
Test driven development follow this pattern: Setup – Execute – Verify the new state. Asking the system under test for its new state has traditionally been done to check the new state. This can create problems with the Law of Demeter. The system under test knows unnecessary much about the objects it is collaborating with.
Unit testing seems to be the most natural way for programmers to test their own code. In this small blog post, Henrik Warne shares some of the issues that people have when they switch from manual testing to a unit testing framework like JUnit.
Intern is an open source software testing tool for Javascript. It runs tests using the browser or node.js and seamlessly integrates with SauceLabs or Selenium. You can write tests using object, TDD, or BDD styles and get full code coverage reporting with Istanbul. This article by Alvin Liu, Todd Kaplinger and Mingzhe Huang provides a presentation of Intern and explains how to use it to test web applications.
One of the most discussed question when people talk about unit testing is what a “unit” is? In this blog post, Ken Baltrinic tries to answer this question.
Better Unit Testing with Microsoft Fakes is a free e-book that discusses the topic of Microsoft Fakes. Microsoft Fakes is a code isolation framework for Visual Studio that helps you isolate the code for unit testing by replacing other parts of the application with stubs or shims. With Microsoft Fakes you can test parts of your software even if some parts have not been implemented or are not working yet.
Test-Driven Development (TDD) can be difficult to practice as features increase in complexity. Testing is often skipped when developers feel uncomfortable with TDD or have not yet seen certain approaches in practice. This video describes specific techniques used in TDD which touch on: Integration testing with RSpec+Capybara, Model Associations and Data Validations, Asynchronous Jobs, Emails, 3rd Party Services, and JSON API endpoints.