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


How to programmatically validate BPMN models

Author: Dmitrii Pisarenko

Did it happen to you? Someone makes a minor change to the BPMN model, then, when the system is deployed the next time, the deployment fails because Camunda thinks that BPMN file is invalid. (Even though all the tests are green.) There is a way to catch such errors earlier – in scope of automated […]

read more

Connect Excel and DMN

Author: Clemens Zumpf

Entering hundreds of lines into any program by hand is not the most satisfying work and a waste of time, if you consider the fact that Excel or other spreadsheet programs could reduce that time drastically. You are not able to copy and paste multiple lines into a DMN while editing it with the Camunda […]

read more

Consume REST Services in Camunda via Java Service Tasks

Author: Maximilian Kamenicky

Learn more about HOW you can call and consume REST Webservices with Camunda. In this blog series, our expert will show you 2 ways to accomplish this. This videoblog focuses on showing how to do that via Java Service Tasks. The second blog in this series will focus on how this can be achieved via […]

read more