Tag Archives: TDD

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

BDD Assistant: It’s alive and cries for help

tutorialStoryOperationsI’ve been working with BDD for years and felt that it needed an application that would facilitate the Behaviour-driven development work-flow. It would need to be made in a away that anyone can use it. By anyone I mean people with or without technical skills. Coders, testers, analysts, managers, business, etc. In that spirit, I started working on BDD Assistant. It is an open source application that can be used to create, manage and run BDD stories.

Now I feel that it is finally ready to go public. The application is far from being finished but there is enough done for the community to see what it’s all about. More information can be found in the BDD Assistant site. Latest release can be downloaded from our GitHub repo. Live demo (with some features disabled due to hosting limitations) can be seen from the BDD Assistant demo.
Continue reading

Continuous Delivery: Unit Tests

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

In the previous article we explored static analysis as one of the first steps in Continuous Delivery. Our journey will continue with unit tests.

Unit Tests

tddBestPracticesAllTestsPassUnit tests are probably the most important part of Continuous Delivery. While unit tests cannot substitute integration and functional tests, they are very easy to write and should be very fast to execute. As any other type of tests, each unit test should be independent of each other. What differentiates unit from other types of tests (integration, functional) is the scope. Each unit test should verify only a single unit of code (method, class, etc). Main benefit of unit tests are that they can find problems early due to their speed of execution. When ease of writing is combined with very short execution time it is no wonder that unit test often represent biggest part of automated tests.
Continue reading

Tests as documentation

origin_2389320345Documentation needs to be comprehensive, always up-to-date and accessible. By comprehensive I mean that it must cover all important areas of the code as well as all functions of the application. While importance of documentation is obvious to most, many struggle without success to have it accurate and up-to-date. Response to “poor” documentation is often assignment of more resources and more time. More often than not, documentation is created for wrong reasons.

Continue reading

Application development: front-end solution with JavaScript

In the previous article we developed the back-end solution for our books application. This article will continue where we stopped.

We’ll develop a front-end solution that can be used with any back-end (Web, mobiles…). You can build on top of the back-end from the previous article (Java, Jersey, Grizzly…) or on top of any other as long as supported services are the same.

The goal of the application is to be able to administer books. In particular, we’ll develop the front-end solution for that application that should be able to:

  • Add new book
  • Update existing book
  • Delete an existing book
  • List all books
  • Display details of the selected book
    Continue reading

Application Development: Back-End Solution With Java

In this article we’ll develop a back-end solution that can be used with any front-end (Web, mobiles…). In the next article we’ll extend on this example and work on the front-end using AngularJS, JQuery and Bootstrap CSS.

The goal of the application is to be able to administer books. In particular, we’ll develop the back-end solution for that application that should be able to:

  • Add new book
  • Update existing book
  • Delete an existing book
  • List all books
  • Display details of the selected book
  • Delete all books
    Continue reading

Scala Tutorial Through Katas: Reverse Polish Notation (Medium)

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

This article is part of the series “Scala Tutorial Through Katas”. Articles are divided into easy, medium and hard. Beginners should start with easy ones and move towards more complicated once they feel more comfortable programming in Scala.

For the complete list of Scala katas and solutions please visit the index page
Continue reading

Learning Python through Katas, TDD and CyberDojo

DISCLAIMER: This is not a tutorial on how to learn Python, in fact, I have never used Python before so don’t take me as example. What I want to share with you is how to learn a new language, strenghen the TDD principles and practice a Kata in an easy way.

Last week I attended the Global day of Code retreat in Barcelona. It was a wonderful experience that generated me a lot of energy to code again (I became a manager some time ago and I don’t code as often as I’d like to). That day we used the Conway’s Game of Life which I recommend to practice the TDD approach.

After investigating about several other katas I stumbled upon the Cyber dojo online tool. Basically this is a web page in which you can practice any kata and choose among more than 20 languages you want to learn without the need to do any setup at all. In other words, if you want to grasp the basics for a new language, this is the perfect place.

Also, one of the nice features from Cyber dojo is that after you’re done with all the coding you wanted to do, you can download all your changes into a zipped Git file and then you have the repository with all the changes that you worked on.

Continue reading