Continuous Delivery: Code Coverage

This article is part of the Continuous Integration, Delivery and Deployment series.

In the previous article we explored unit tests as the first and fastest set of tests we should run. Now it’s time to see whether our unit tests provide enough code coverage.

Code Coverage

Unit tests by themselves do not provide enough confidence unless we know that they cover significant code coverage. Having all tests successful while, for example, covering only 15% of the code cannot provide enough trust.

Mature teams might not need to measure code coverage. They might know from experience that their unit tests are covering as much code as the project they’re working on needs. Teams like that tend to have years of practice with Test-driven development (TDD). However, for the majority of us, tools that measure the coverage are very indeed useful addition to our tool-belt.
Continue reading

JavaScript Tutorial Through Katas: Mars Rover

A programming kata is an exercise which helps a programmer hone his skills through practice and repetition.

The article assumes that the reader is familiar with the basic usage of JavaScript and Jasmine asserts and knows how to run them from his favorite IDE (mine is WebStorm or IntelliJ IDEA).

Tests that prove that the solution is correct are displayed below. Recommended way to solve this kata is to write the implementation for the first test, confirm that it passes and move to the next. Once all of the tests pass, the kata can be considered solved.
Continue reading

Test-Driven Development (TDD)

What is Test-Driven Development (TDD)?

large__8282043567Test-Driven Development is a process that relies on the repetition of very short development cycle. It is based on the test-first concept of Extreme Programming (XP) that encourages simple design with high level of confidence.

The procedure of doing TDD is following:

  1. Write a test
  2. Run all tests
  3. Write the implementation code
  4. Run all tests
  5. Refactor
    Continue reading

Scala Test-Driven Development (TDD): Unit Testing File Operations with Specs2 and Mockito

In this article we’ll go through the exercise of writing a method that will write string content to the specified file. There will be an option to specify whether we should overwrite an existing file. In addition, directories should be created if they do not already exist.

Programming language is Scala and testing framework that will be used is Specs2. In the spirit of unit testing, instead of interactions with the file system we’ll use mocks with Mockito (already included in Specs2). All the code will be done using Test-Driven Development (TDD).

This article is based on an existing code done for the open source application BDD Assistant located in the TechnologyConversationsBdd repository.

Let’s get started.
Continue reading