JUnit Parameter Resolvers

Today (err, recently) I learned … that JUnit’s extension API allows for parameter resolvers. These kick in every time you use arguments on a test method, lifecycle method or class constructor. For me, so far, none of these methods ever took an argument. But turns out, it’s possible … and even useful. They have a primitive example here where they allow a test method to take a random number like so:...

Status: 🌿 Budding · Planted: Dec 11, 2024 · 1 min

JUnit Assumptions API

Today, I discovered a powerful feature in JUnit: the Assumptions API. This API allows you to define assumptions for your tests. If an assumption isn’t met, the test execution is aborted rather than marked as failed. This distinction is crucial in scenarios like conditional test execution in CI pipelines. When a test is skipped due to an unmet assumption, it appears as “skipped” in the test reports, not as “passed” or “failed....

Status: 🌿 Budding · Planted: Aug 24, 2024 · 1 min