Merv-Local + JUnit 5 guide

Introduction

JUnit 5 is the industry-standard framework for unit and integration testing in Java applications, offering powerful features such as annotations, assertions, parameterized tests, lifecycle management, and extension support. Merv-Local integrates via @ExtendWith(MervJUnitHandler.class) and automatically capturing test execution details and generating rich, interactive HTML reports. These reports, stored in the directory specified by merv.report.folder.

You will learn
  • How to add merv-client-api to Maven or Gradle
  • Minimum merv.properties for local mode
  • How to register MervJUnitHandler on a class or globally
  • How to record info, testdata, and validation steps with MervReporter
  • Optional Selenium/Playwright binding for per-step screenshots
  • How to open live and final suite reports in a browser

Add dependency

Add MERV to your project (use the latest version from Maven Central when available):

<dependency>
  <groupId>io.github.techelliiptica</groupId>
  <artifactId>merv-client-api</artifactId>
  <version>4.0.0</version>
</dependency>

Gradle:

testImplementation "io.github.techelliiptica:merv-client-api:4.0.0"

Configure merv.properties

Place merv.properties in your project root (the directory where you run mvn test or ./gradlew test — typically next to pom.xml).

Sample Configuration

merv.local=true
merv.regression_suite=Your Regression Suite Name
merv.report.folder=./merv-reports

Download sample merv.properties

Common properties

Property Role
merv.local true — Merv-Local: write HTML/JSON reports on disk under merv.report.folder (no cloud API).
false — Merv-Server: send suites, cases, and steps to the MERV cloud API (set merv.server, API key, and hierarchy as well).
merv.report.folder Root for timestamped run folders and index.html dashboard.
merv.regression_suite Suite title in JSON and HTML.
merv.execution.parallel true — parallel @Test methods share one suite folder safely.
false — single-threaded run (default for most suites).
merv.screenshot true (or legacy on / yes) — capture a PNG after each executed step when a WebDriver or Playwright page is bound via MervJUnitHandler.setAutomationToolObject(...).
false — no automatic step screenshots (smaller report folders).

Register JUnit 5 extension

Add the extension to each test class, or register it once for the whole module:

import org.junit.jupiter.api.extension.ExtendWith;
import org.teche.merv.client.plugin.MervJUnitHandler;

@ExtendWith(MervJUnitHandler.class)
class MyTests {
  // @Test methods, @BeforeEach, etc.
}

Note: @ExtendWith need to implement at class level not method level.

Global registration (all tests in the module):

# src/test/resources/junit-platform.properties
junit.jupiter.extensions.autodetection.enabled=true

# src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
org.teche.merv.client.plugin.MervJUnitHandler

Or use a base class with @ExtendWith(MervJUnitHandler.class) that your test classes extend.

JUnit maps each @Test method to a Merv testcase. @BeforeEach, the test body, and @AfterEach appear as steps in the suite report.

Bind automation (optional)

When merv.screenshot=true, register your driver or page before steps that should capture screenshots:

import org.teche.merv.client.plugin.AutomationTool;
import org.teche.merv.client.plugin.MervJUnitHandler;

// Selenium
MervJUnitHandler.setAutomationToolObject(AutomationTool.SELENIUM, driver);

// Playwright Java
MervJUnitHandler.setAutomationToolObject(AutomationTool.PLAYWRIGHT, page);

Clear the binding in @AfterEach with setAutomationToolObject(null, null) when using parallel tests.

Plugin steps in tests

Use MervReporter — the same API as Cucumber and TestNG:

import org.teche.merv.client.plugin.MervReporter;

MervReporter.info("Reached checkout page");
MervReporter.testdata("Request body", jsonPayload);
MervReporter.validation("Order total", expectedTotal, actualTotal);

Each call creates a typed step (INFO, TEST_DATA, ASSERTION) in the live and final HTML reports.

File test data

Attach a file as test data — copies into the report folder and renders inline in HTML when possible:

import java.io.File;
import org.teche.merv.client.plugin.MervReporter;

MervReporter.testdata("Payload", new File("src/test/resources/payload.json"));
MervReporter.testdata("Screenshot ref", new File("screenshots/expected.png"));

Step screenshots

When merv.screenshot=true and a driver is bound, Merv captures a PNG after each executed step and stores it under {runFolder}/screenshots/.

In merv-report.html and merv-report-live.html:

Run tests

mvn test

Gradle: ./gradlew test. Merv creates a timestamped run folder and refreshes index.html while tests execute.

Viewing Merv reports

After a run, reports live under {merv.report.folder} (for example ./merv-reports/). Open paths through a local web server — not via file:// in the file manager.

merv-reports/ index.html # Dashboard (all runs) 15-05-2026 14-23-41 Merv-Report/ json/merv-report.json # Suite + testcase + step data screenshots/ # Step PNGs (when merv.screenshot=true) html/merv-report.html # Final suite report html/merv-report-live.html # Live report during run

Open with a web server

Merv-Local reports load JSON and charts with fetch. Browsers often block that on file:// URLs. Use your IDE’s static server (or any local HTTP server) so the address bar shows http://localhost:….

  1. Install the Live Server extension.
  2. Right-click merv-reports/index.html and choose Open with Live Server.
  3. Open {runFolder}/html/merv-report-live.html on the same server while tests run.
  4. Click a step header with the camera icon to expand step screenshots in the suite report.

Other editors and CI

Any local static server works: npx serve merv-reports or python3 -m http.server --directory merv-reports, then open http://localhost:…/index.html.

Troubleshooting

IssueWhat to check
Blank dashboard or “load issue” Open reports via http://localhost, not file://. Hard-refresh after a new run.
No Merv steps in report Confirm @ExtendWith(MervJUnitHandler.class) (or global extension) is active. Use MervReporter for custom steps.
No step screenshots Set merv.screenshot=true and call MervJUnitHandler.setAutomationToolObject(...) before the step runs.
Click step but no image Re-run tests after upgrading merv-client-api to 4.0.0+. Confirm screenshots/*.png exists under the run folder.
Server mode instead of local Ensure merv.local=true in merv.properties on the test classpath.

What’s next

← Back to Documentation