We publish test reports in Continuous Integration (CI) to see test results easily after every code change. It helps teams quickly find and fix problems.
Report publishing in CI in Selenium Java
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class TestReportPublisher { @Test public void sampleTest() { // Your Selenium test code here Assertions.assertTrue(true); } @AfterAll public static void publishReport() { // Code to publish or archive test reports in CI // Usually handled by CI tool configuration } }
Test report publishing is often configured in the CI tool, not fully in code.
Use test frameworks like JUnit or TestNG that generate reports automatically.
/* Example: JUnit test with Maven Surefire plugin generates reports automatically */ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class SimpleTest { @Test public void testExample() { Assertions.assertEquals(5, 2 + 3); } }
/* Jenkins pipeline snippet to publish JUnit reports */ pipeline { stages { stage('Test') { steps { sh 'mvn test' junit 'target/surefire-reports/*.xml' } } } }
/* GitHub Actions step to publish test reports */ - name: Run tests run: mvn test - name: Publish test report uses: actions/upload-artifact@v3 with: name: test-report path: target/surefire-reports/
This simple JUnit test shows a passing test. The message after all tests reminds that report publishing is handled by CI tools.
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class ReportPublishingTest { @Test public void simpleTest() { Assertions.assertTrue(3 > 1); } @AfterAll public static void publishReport() { // In real CI, reports are published by CI tool, not code System.out.println("Test completed. Reports are generated by the test framework and published by CI."); } }
CI tools like Jenkins, GitHub Actions, or GitLab CI handle report publishing using plugins or built-in steps.
Test frameworks generate reports in formats like XML or HTML automatically during test runs.
Common mistake: expecting code to publish reports directly instead of configuring the CI tool properly.
Publishing test reports in CI helps teams see test results quickly after code changes.
Test frameworks generate reports; CI tools publish and display them.
Configure your CI pipeline to collect and show these reports for best results.