Blog

25.02.2021. | Author: 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

More Blog articles

04.04.2022.

Maler oder Macher sein

Author: Mirko Pawlak

Digitale Transformation ohne Grenzen. Ich bin Prozessmacher. Ich hocke tief drinnen im Maschinenraum und schau mir an, was das Unternehmen einzigartig macht. Ich tu das gern, denn jeder Prozess ist lebendig und einzigartig. Es gibt einen Anfang, dann passiert etwas und am Ende ist es vorbei. Wie geht man am besten mit seinen Prozessen um? […]

read more
02.12.2021.

How to deploy a Camunda Spring Boot application to a shared application server

Author: Maximilian Kamenicky

Context Do you still remember our Blog: How to deploy a Camunda Spring Boot application to an external application server? In that blog, my colleague Gerardo Manzano Garcia explained the steps necessary to run a spring boot application on a dedicated application server i.e. an external Tomcat. In other words, run the spring boot application […]

read more
15.11.2021.

Ways to integrate Kafka with Databases

Author: Denis Savenko

Kafka is a great instrument. It is widely used in event-driven architectures, and it does the job perfectly fine. However, this is not the only use-case for it. Kafka is also very well suitable for data replication and ingestion use-cases, as well as for building modern ETL or ELT pipelines. The most noteworthy reasons for […]

read more