public abstract class TestBase extends Object implements org.junit.jupiter.api.extension.BeforeEachCallback
InterceptorManager.| Modifier and Type | Field and Description |
|---|---|
protected InterceptorManager |
interceptorManager |
protected TestContextManager |
testContextManager |
protected TestResourceNamer |
testResourceNamer |
| Constructor and Description |
|---|
TestBase() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterTest()
Dispose of any resources and clean-up after a test case runs.
|
void |
beforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) |
protected void |
beforeTest()
Performs any set-up before each test case.
|
TestMode |
getTestMode()
Gets the TestMode that has been initialized.
|
protected String |
getTestName()
Deprecated.
This method is deprecated as JUnit 5 provides a simpler mechanism to get the test method name through
TestInfo. Keeping this for backward compatability of other client libraries that still override this
method. This method can be deleted when all client libraries remove this method. See TestBase.setupTest(TestInfo). |
static void |
setupClass()
Before tests are executed, determines the test mode by reading the
TestBase.AZURE_TEST_MODE environment
variable. |
void |
setupTest(org.junit.jupiter.api.TestInfo testInfo)
Sets-up the
TestBase.testResourceNamer and TestBase.interceptorManager before each test case is
run. |
protected void |
sleepIfRunningAgainstService(long millis)
Sleeps the test for the given amount of milliseconds if
TestMode isn't TestMode.PLAYBACK. |
void |
teardownTest(org.junit.jupiter.api.TestInfo testInfo)
Disposes of
InterceptorManager and its inheriting class' resources. |
protected InterceptorManager interceptorManager
protected TestResourceNamer testResourceNamer
protected TestContextManager testContextManager
@BeforeAll public static void setupClass()
TestBase.AZURE_TEST_MODE environment
variable. If it is not set, TestMode.PLAYBACKpublic void beforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback@BeforeEach public void setupTest(org.junit.jupiter.api.TestInfo testInfo)
TestBase.testResourceNamer and TestBase.interceptorManager before each test case is
run. Then calls its implementing class to perform any other set-up commands.testInfo - TestInfo to retrieve test method name.@AfterEach public void teardownTest(org.junit.jupiter.api.TestInfo testInfo)
InterceptorManager and its inheriting class' resources.testInfo - the injected testInfopublic TestMode getTestMode()
@Deprecated protected String getTestName()
TestInfo. Keeping this for backward compatability of other client libraries that still override this
method. This method can be deleted when all client libraries remove this method. See TestBase.setupTest(TestInfo).protected void beforeTest()
protected void afterTest()
protected void sleepIfRunningAgainstService(long millis)
TestMode isn't TestMode.PLAYBACK.millis - Number of milliseconds to sleep the test.IllegalStateException - If the sleep is interrupted.Copyright © 2020 Microsoft Corporation. All rights reserved.