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.
- How to add
merv-client-apito Maven or Gradle - Minimum
merv.propertiesfor local mode - How to register
MervJUnitHandleron a class or globally - How to record
info,testdata, andvalidationsteps withMervReporter - 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"));
- Text / JSON / CSV / Java — inline preview in the step
- Images — inline thumbnail; click to zoom
- Other files — download bar (max 20 MB per file)
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:
- Steps with screenshots show a camera icon on the title
- Click the step header (title + status row) to show or hide the screenshot
- Use the toolbar Show screenshots toggle for the screenshot movie; per-step toggles still work when it is off
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.
index.html— dashboard: suite grid, KPI charts, consolidated views{runFolder}/html/merv-report.html— final suite report for one run{runFolder}/html/merv-report-live.html— live suite view while tests run (polls JSON every 5s)
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:….
- Install the Live Server extension.
- Right-click
merv-reports/index.htmland choose Open with Live Server. - Open
{runFolder}/html/merv-report-live.htmlon the same server while tests run. - Click a step header with the camera icon to expand step screenshots in the suite report.
- Right-click
merv-reports/index.htmland choose Open in Browser. - Open suite reports from
{runFolder}/html/the same way. - Confirm the address bar shows
http://localhost:…, notfile://.
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
| Issue | What 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
- Merv documentation — pick another framework
- Cucumber guide · TestNG guide
- Merv-Server guide — send JUnit results to the cloud
- Sample local report
- Home — product overview and screenshots
MERV