Class RestoreSystemPropertiesExt

  • All Implemented Interfaces:
    org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.Extension

    public class RestoreSystemPropertiesExt
    extends Object
    implements org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback
    JUnit 5 extension for preserving and restoring system properties around test executions.

    Annotate each test method that modifies system properties using @ExtendWith(RestoreSystemPropertiesExt.class)

    • Constructor Detail

      • RestoreSystemPropertiesExt

        public RestoreSystemPropertiesExt()
    • Method Detail

      • beforeTestExecution

        public void beforeTestExecution​(org.junit.jupiter.api.extension.ExtensionContext ec)
                                 throws Exception
        Specified by:
        beforeTestExecution in interface org.junit.jupiter.api.extension.BeforeTestExecutionCallback
        Throws:
        Exception
      • afterTestExecution

        public void afterTestExecution​(org.junit.jupiter.api.extension.ExtensionContext ec)
                                throws Exception
        Specified by:
        afterTestExecution in interface org.junit.jupiter.api.extension.AfterTestExecutionCallback
        Throws:
        Exception