TestContextManager Class

  • java.lang.Object
    • com.azure.core.test.TestContextManager

public class TestContextManager

This class handles managing context about a test, such as custom testing annotations and verifying whether the test is capable of running.

Constructor Summary

Constructor Description
TestContextManager(Method testMethod, TestMode testMode)

Constructs a TestContextManager based on the test method.

TestContextManager(Method testMethod, TestMode testMode, boolean enableTestProxy, boolean recordWithoutRequestBodyClassAnnotation, Path testClassPath)

Constructs a TestContextManager based on the test method.

TestContextManager(Method testMethod, TestMode testMode, boolean enableTestProxy, boolean recordWithoutRequestBodyClassAnnotation, Path testClassPath, String trackerTestName)

Constructs a TestContextManager based on the test method.

Method Summary

Modifier and Type Method and Description
boolean didTestRun()

Returns whether the current test was ran.

boolean doNotRecordTest()

Returns whether the test should have its network calls recorded during a RECORD test run.

TestMode getTestMode()

Returns the mode being used to run tests.

String getTestName()

Returns the name of the test being ran.

String getTestPlaybackRecordingName()

Returns the name of the playback record for the test being ran.

String getTrackerTestName()

Gets the formatted name of the test used to log and track its progress.

boolean isTestProxyEnabled()

Returns if the test proxy is enabled

void setTestIteration(Integer testIteration)

Sets the test iteration for parameterized tests.

boolean skipRecordingRequestBody()

Returns whether the test is recording request body when run RECORD mode.

Methods inherited from java.lang.Object

Constructor Details

TestContextManager

public TestContextManager(Method testMethod, TestMode testMode)

Constructs a TestContextManager based on the test method.

Parameters:

testMethod - Test method being ran.
testMode - The TestMode the test is running in.

TestContextManager

public TestContextManager(Method testMethod, TestMode testMode, boolean enableTestProxy, boolean recordWithoutRequestBodyClassAnnotation, Path testClassPath)

Constructs a TestContextManager based on the test method.

Parameters:

testMethod - Test method being ran.
testMode - The TestMode the test is running in.
enableTestProxy - True if the external test proxy is in use.
recordWithoutRequestBodyClassAnnotation - flag indicating if RecordWithoutRequestBody annotation present on test class.
testClassPath - the test class path

TestContextManager

public TestContextManager(Method testMethod, TestMode testMode, boolean enableTestProxy, boolean recordWithoutRequestBodyClassAnnotation, Path testClassPath, String trackerTestName)

Constructs a TestContextManager based on the test method.

Parameters:

testMethod - Test method being ran.
testMode - The TestMode the test is running in.
enableTestProxy - True if the external test proxy is in use.
recordWithoutRequestBodyClassAnnotation - flag indicating if RecordWithoutRequestBody annotation present on test class.
testClassPath - the test class path
trackerTestName - The formatted test name used in logging and tracking its progress.

Method Details

didTestRun

public boolean didTestRun()

Returns whether the current test was ran.

Returns:

Flag indicating whether the current test was ran.

doNotRecordTest

public boolean doNotRecordTest()

Returns whether the test should have its network calls recorded during a RECORD test run.

Returns:

Flag indicating whether to record test network calls.

getTestMode

public TestMode getTestMode()

Returns the mode being used to run tests.

Returns:

The TestMode being used to run tests.

getTestName

public String getTestName()

Returns the name of the test being ran.

Returns:

The test name.

getTestPlaybackRecordingName

public String getTestPlaybackRecordingName()

Returns the name of the playback record for the test being ran.

Returns:

The playback record name.

getTrackerTestName

public String getTrackerTestName()

Gets the formatted name of the test used to log and track its progress.

Returns:

The formatted test name.

isTestProxyEnabled

public boolean isTestProxyEnabled()

Returns if the test proxy is enabled

Returns:

True if the text proxy is enabled

setTestIteration

public void setTestIteration(Integer testIteration)

Sets the test iteration for parameterized tests.

Parameters:

testIteration - Test iteration.

skipRecordingRequestBody

public boolean skipRecordingRequestBody()

Returns whether the test is recording request body when run RECORD mode.

Returns:

Flag indicating whether test should record request bodies.

Applies to