25.02.2021. | Autor: Eni Sinanaj

Producing code like the PROs

The importance of TDD (Test-Driven Development)

Test-driven development is a methodology for software development that relies on the repetition of a short development cycle.

Read more about TDD in our previous blog here.

This short life-cycle is as follows:

  • Write the test
  • Run the test (there is no implementation code, test does not pass)
  • Write just enough implementation code to make the test pass
  • Run all tests (tests pass)
  • Refactor
  • Repeat

This cycle is often called also Red-Green-Refactor.

The idea is not to make the implementation final, but to provide just enough code for tests to pass. Once everything is green we can proceed to refactor the existing code. That means that we are making the code more optimum without introducing new features. While refactoring is in place, all tests should be passing all the time. If one of them fails, refactor broke an existing functionality. Refactoring should not include new tests.

Test-driven development is about development (and design), specifically improving the quality and design of code rather then about testing. The resulting unit tests are just an extremely useful by-product.

The T in TDD often confuses but what we really need this approach for is to force us to thinking about the implementation before writing the code.

Requirements of TDD are that our units can be easily mocked or stubbed. This forces us to have a clean design and be independent from external tools. For example in our unit tests we don’t need to connect to the database but mock it.

Another really nice feature that comes free with TDD is documentation. Sometimes by just reading the tests, one should understand what an implementation is for.

TDD is an awesome tool that we have that takes time to master but once understood productivity and quality increase drastically.

Eni Sinanaj
JIT Senior Software Engineer

Photo by Florian Olivo on Unsplash

Weitere Blog


Gaps in the automation age

Autor: JIT

Creative solutions and approaches are needed to enable any person to seize new opportunities in the automation age, without them, groups at disadvantage may fall behind in the world of work. In one of our previous post, when we talked about who the main drivers of automation are, we concluded human beings. In this post, […]

Blog lesen

Running a Camunda Meetup Group: Vienna

Autor: Maximlian Kamenicky

Ever wondered what it is like to host a meetup? If you consider organizing a community project like that, it can help to get some insights on what to expect. As a sponsor and co-organizer of a big meetup, JIT can give you exactly this input. Since Martin Schimak founded the meetup in 2016, it […]

Blog lesen

First Day at Work

Autor: Sebastian Schmid

This is a story about my way to the Camunda Certified Engineer while working at „J-IT“ IT-Dienstleistungs GesmbH. As you can imagine, the very first thing to do when starting at a new company is inspecting the Coffee Machines. Good for me, I found out that we have two of them. While I’m not a […]

Blog lesen