Class JunitExtension

  • All Implemented Interfaces:
    org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.TestWatcher

    public class JunitExtension
    extends AbstractTestFrameworkListener
    implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.TestWatcher
    JUnit 5 extension for Testomat.io integration. Reports JUnit test execution results to Testomat.io platform. Usage: Add @ExtendWith(JUnitExtension.class) to test classes.
    • Constructor Detail

      • JunitExtension

        public JunitExtension()
        Creates new JUnit extension.
    • Method Detail

      • beforeAll

        public void beforeAll​(org.junit.jupiter.api.extension.ExtensionContext context)
        Called before all tests in a class. Starts test suite tracking.
        Specified by:
        beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
        Parameters:
        context - JUnit extension context
      • afterAll

        public void afterAll​(org.junit.jupiter.api.extension.ExtensionContext context)
        Called after all tests in a class. Finishes test suite tracking.
        Specified by:
        afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
        Parameters:
        context - JUnit extension context
      • beforeEach

        public void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
        Called before each test method execution.
        Specified by:
        beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
        Parameters:
        extensionContext - JUnit extension context
      • testDisabled

        public void testDisabled​(org.junit.jupiter.api.extension.ExtensionContext context,
                                 Optional<String> reason)
        Called when a test is disabled. Reports test as skipped.
        Specified by:
        testDisabled in interface org.junit.jupiter.api.extension.TestWatcher
        Parameters:
        context - JUnit extension context
        reason - optional reason for disabling the test
      • testSuccessful

        public void testSuccessful​(org.junit.jupiter.api.extension.ExtensionContext context)
        Called when a test completes successfully. Reports test as passed.
        Specified by:
        testSuccessful in interface org.junit.jupiter.api.extension.TestWatcher
        Parameters:
        context - JUnit extension context
      • testAborted

        public void testAborted​(org.junit.jupiter.api.extension.ExtensionContext context,
                                Throwable cause)
        Called when a test is aborted. Reports test as skipped.
        Specified by:
        testAborted in interface org.junit.jupiter.api.extension.TestWatcher
        Parameters:
        context - JUnit extension context
        cause - exception that caused the abort
      • testFailed

        public void testFailed​(org.junit.jupiter.api.extension.ExtensionContext context,
                               Throwable cause)
        Called when a test fails. Reports test as failed.
        Specified by:
        testFailed in interface org.junit.jupiter.api.extension.TestWatcher
        Parameters:
        context - JUnit extension context
        cause - exception that caused the failure