Disabled JUnit 5 tests with expiry date

Anders Sveen
1 min readOct 1, 2021

--

Photo by Vinicius Marques on Unsplash

Working in fintech brings many surprises, and one of them is the fact that some vendors don’t have very stable test environments. When we point out that it isn’t working anymore, it might take a while for it to get fixed.

While the issue is being fixed, we need a way to disable tests so our pipelines doesn’t grind to a halt.

We have done this with ignoring tags when building (in Gradle). But we sometimes forget to remove the tags after the problem is fixed. Then the problem is fixed, and suddenly you discover that it’s been several weeks since any automated tests for that integration partner has run.

So we ended up creating a small JUnit 5 extension that lets us set an end date for the @Disabled annotation. It’s a bit pain in the ass when the test starts running again and the problem isn’t fixed, but at least we don’t forget about it.

Here’s how to:

JUnit 5 Extensions are quite flexible in general, and it really pays off knowing how to use and create custom ones. 😃

--

--

Anders Sveen
Anders Sveen

Written by Anders Sveen

Passionate agile developer and mentor for hire @ Mikill Digital

No responses yet