Export definitions as file
From release 2.0.0, CodeSV provides functionality for exporting endpoint definitions from code into json transaction DSL file. This way developers using CodeSV can share the artifacts they created in code with other team members who can use and augment with Mock Services UI in Blazemeter Mock Services and spin up Mock Services hosting content imported from the code.
Usage
There are three available options for export.
Export to out directory
Using method exportDslAsFile()
would export definitions to out/stubs directory in project root.
public class CodeSVExportExampleTest { @Rule public VirtualServerRule vs = new VirtualServerRule(); private TxnRepoStore store = new TxnRepoStoreBuilder() .exportDslAsFile() .build(this); @Test public void codesvExportExampleTest() { forGet("http://blazedemo.com/cities") .doReturn(okMessage().withJsonBody("...cities...")); /* rest of the test */ } }
Export to custom directory
Using method exportDslAsFile(String dir)
would export definitions to custom directory in project root.
Export to custom directory using system property
Setting system propety System.setProperty("repository.dsl.export", DIR_NAME)
would also export definitions to custom directory in project root.
Supported matchers
CodeSV supports using hamcrest and in-build matchers in request definitions. To make it compatible with BlazeSV, we introduced export only for the next matchers:
- HttpFluentInterface.isEqualTo()
- HttpFluentInterface.matchesRegex()
- CoreMatchers.not(HttpFluentInterface.matchesRegex())
- HttpFluentInterface.isEqualTo()
- HttpFluentInterface.isEqualIgnoringCaseTo()
- XmlLoadingMatcher(HasXPath.hasXPath())
- XmlEqualsMatcher()
- JsonLoadingMatcher(JsonPathMatchers.hasJsonPath())
- JsonEqualsMatcher()
- absentHeader()/absentQuery()/absentCookie()/absentBodyPayload()