public abstract class TestBase extends Object implements org.junit.jupiter.api.extension.BeforeEachCallback
InterceptorManager.| Modifier and Type | Field and Description |
|---|---|
static String |
AZURE_TEST_HTTP_CLIENTS_VALUE_ALL |
static String |
AZURE_TEST_HTTP_CLIENTS_VALUE_NETTY |
static String |
AZURE_TEST_SERVICE_VERSIONS_VALUE_ALL |
protected InterceptorManager |
interceptorManager |
protected TestContextManager |
testContextManager |
protected com.azure.core.test.utils.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.
|
static Stream<HttpClient> |
getHttpClients()
Returns a list of
HttpClients that should be tested. |
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. |
static boolean |
shouldClientBeTested(HttpClient client)
Returns whether the given http clients match the rules of test framework.
|
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. |
public static final String AZURE_TEST_HTTP_CLIENTS_VALUE_ALL
public static final String AZURE_TEST_HTTP_CLIENTS_VALUE_NETTY
public static final String AZURE_TEST_SERVICE_VERSIONS_VALUE_ALL
protected InterceptorManager interceptorManager
protected com.azure.core.test.utils.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()
public static Stream<HttpClient> getHttpClients()
HttpClients that should be tested.HttpClients to be tested.public static boolean shouldClientBeTested(HttpClient client)
set AZURE_TEST_HTTP_CLIENTS = NettyAsyncHttpClient, OkHttpAsyncHttpClientclient - Http client needs to checkprotected 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.