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
ConstructorsConstructorDescriptionCreates a newManualRestDocumentationinstance that will generate snippets to <gradle/maven build path>/generated-snippets.ManualRestDocumentation(String outputDirectory) Creates a newManualRestDocumentationinstance that will generate snippets to the givenoutputDirectory. -
Method Summary
Modifier and TypeMethodDescriptionvoidNotification that a test has completed.Returns aRestDocumentationContextfor the operation that is about to be performed.voidbeforeTest(Class<?> testClass, String testMethodName) Notification that a test is about to begin.
-
Constructor Details
-
ManualRestDocumentation
public ManualRestDocumentation()Creates a newManualRestDocumentationinstance that will generate snippets to <gradle/maven build path>/generated-snippets. -
ManualRestDocumentation
Creates a newManualRestDocumentationinstance that will generate snippets to the givenoutputDirectory.- Parameters:
outputDirectory- the output directory
-
-
Method Details
-
beforeTest
Notification that a test is about to begin. Creates aRestDocumentationContextfor the test on the giventestClasswith 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 theRestDocumentationContextthat was previously established by a call tobeforeTest(Class, String). -
beforeOperation
Description copied from interface:RestDocumentationContextProviderReturns aRestDocumentationContextfor the operation that is about to be performed.- Specified by:
beforeOperationin interfaceRestDocumentationContextProvider- Returns:
- the context for the operation
-