Sitemap
CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Follow publication

Member-only story

Making A Java Unit Testing Framework From Scratch

12 min readNov 1, 2021

--

Photo by Quino Al on Unsplash

JUnit was one of the major breakthroughs in Java programming. In the couple of decades since version 1.0 first came out, JUnit has become so entrenched that most Java programmers now take it for granted.

Legend has it that JUnit, perhaps the most famous unit testing framework ever, was created with test-driven development (TDD).

How was that even possible? It seems kind of circular. But I also have an inkling of maybe how it was done. So I decided to give it a try by creating a testing framework from scratch.

I’m not saying that this is exactly how JUnit was created, I’m only suggesting that it could have been created as I will show in this article.

As you probably know, TDD is a process in which you start with a failing test, change the unit being tested to pass the test, refactor if needed. Then you repeat the process with the next test, until the whole program works the way you want it to work.

With the TDD process, you turn Murphy’s law to your advantage. Whatever can go wrong will go wrong, but if you can foresee how things will go wrong, you can make sure things go wrong during development, when problems are easy to fix, rather than in production, when problems are harder to fix.

--

--

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Alonso Del Arte
Alonso Del Arte

Written by Alonso Del Arte

is a Java and Scala developer from Detroit, Michigan. AWS Cloud Practitioner Foundational certified

No responses yet