38. Test Reporting, Video Recording & CI Artifact Management

Enabling Video Recording & Artifacts

// Record videos for failed tests:
BrowserContext context = browser.newContext(new Browser.NewContextOptions()
    .setRecordVideoDir(Paths.get("videos/"))
    .setRecordVideoSize(1280, 720));

Page page = context.newPage();
// Run test...

// Save video path on test failure:
context.close();
System.out.println("Video saved to: " + page.video().path());

Clean Test Execution Summary

public class TestResultSummary {
    private final int total;
    private final int passed;
    private final int failed;

public TestResultSummary(int total, int passed, int failed) {
this.total = total;
this.passed = passed;
this.failed = failed;
}

public double getPassRate() {
return total == 0 ? 0 : ((double) passed / total) * 100.0;
}
}

Task

  • Implement calculatePassRate:
  • 1. Accept int passed and int total.
  • 2. If total == 0, return 0.0.
  • 3. Otherwise return ((double) passed / total) * 100.0.
πŸ’‘Common doubts
Did you like the problem?
Lesson 38 of 38
Java
Loading code editor…