Comparative analysis of Java unit and integration testing tools: JUnit, TestNG and Spock

Main Article Content

Dawid Grabek

dawid.grabek@pollub.edu.pl

Jan Gryta

jan.gryta@pollub.edu.pl

Mariusz Dzieńkowski

m.dzienkowski@pollub.pl

https://orcid.org/0000-0002-1932-297X

Abstract

The purpose of the study is to compare popular Java testing tools: JUnit, TestNg and Spock. The evaluation was con-ducted based using four criteria: performance, popularity, ease of learning, and code readability. A quantitative analysis was performed based on an experiment with predefined research scenarios, which included assertion tests, database operations, and computational tasks. Execution times of the scenarios were measured in various configurations of single-threaded and multi-threaded tests. The comparative analysis showed that no single tool is universally optimal. Spock demonstrates superior performance in terms of code readability and clarity. TestNG, by contrast, offers high execution performance and requires relatively little effort to learn and use effectively. JUnit stands out particularly in its support for multithreaded data access. The results therefore challenge the widely held belief in the JUnit framework's universality.

Keywords:

software testing, Java code testing, unit tests, integration tests, JUnit, TestNg, Spock

Sustainable Development Goals (SDG)

  • 9 - Industry, Innovation, Technology and Infrastructure

References

Article Details

Grabek, D., Gryta, J., & Dzieńkowski, M. (2026). Comparative analysis of Java unit and integration testing tools: JUnit, TestNG and Spock. Informatyka, Automatyka, Pomiary W Gospodarce I Ochronie Środowiska, 16(2), 145–151. https://doi.org/10.35784/iapgos.8302