Package org.springframework.restdocs
Class ManualRestDocumentation
java.lang.Object
org.springframework.restdocs.ManualRestDocumentation
- All Implemented Interfaces:
RestDocumentationContextProvider
public final class ManualRestDocumentation
extends Object
implements RestDocumentationContextProvider
ManualRestDocumentation
is used to manually manage the
RestDocumentationContext
. Primarly intended for use with TestNG, but suitable
for use in any environment where manual management of the context is required.
Users of JUnit should use JUnitRestDocumentation
and take advantage of its
Rule-based support for automatic management of the context.
- Since:
- 1.1.0
- Author:
- Andy Wilkinson
-
Constructor Summary
ConstructorDescriptionCreates a newManualRestDocumentation
instance that will generate snippets to <gradle/maven build path>/generated-snippets.ManualRestDocumentation
(String outputDirectory) Creates a newManualRestDocumentation
instance that will generate snippets to the givenoutputDirectory
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Notification that a test has completed.Returns aRestDocumentationContext
for the operation that is about to be performed.void
beforeTest
(Class<?> testClass, String testMethodName) Notification that a test is about to begin.
-
Constructor Details
-
ManualRestDocumentation
public ManualRestDocumentation()Creates a newManualRestDocumentation
instance that will generate snippets to <gradle/maven build path>/generated-snippets. -
ManualRestDocumentation
Creates a newManualRestDocumentation
instance that will generate snippets to the givenoutputDirectory
.- Parameters:
outputDirectory
- the output directory
-
-
Method Details
-
beforeTest
Notification that a test is about to begin. Creates aRestDocumentationContext
for the test on the giventestClass
with the giventestMethodName
. Must be followed by a call toafterTest()
once the test has completed.- Parameters:
testClass
- the test classtestMethodName
- the name of the test method- Throws:
IllegalStateException
- if a context has already be created
-
afterTest
public void afterTest()Notification that a test has completed. Clears theRestDocumentationContext
that was previously established by a call tobeforeTest(Class, String)
. -
beforeOperation
Description copied from interface:RestDocumentationContextProvider
Returns aRestDocumentationContext
for the operation that is about to be performed.- Specified by:
beforeOperation
in interfaceRestDocumentationContextProvider
- Returns:
- the context for the operation
-