GitBucket
4.22.0
Toggle navigation
Sign in
Files
Branches
5
Releases
4
Issues
Pull requests
2
Labels
Priorities
Milestones
Wiki
Forks
1
seiji
/
mocking
forked from
sogabe/mocking
Browse code
fixed test
PR
1 parent
1d5dc8e
commit
6e5daada88ef2a666f6a8c5bed8ed3b200e82f61
Seiji Sogabe
authored
on 26 Jun
Patch
Showing
1 changed file
README.md
Ignore Space
Show notes
View
README.md
# Mocking [](http://ci.buildria.com/job/mocking/) Mocking is a test framework which is inspired by [Restito](https://github.com/mkotsur/restito). Mocking provides a DSL to: * Mimic rest server behavior * Record HTTP calls to the server * Perform verification against happened calls * Automatic serialization ## Static import In order to use Mocking effectively, it's recommended to statically import methods from the following classes: ``` java import static com.buildria.mocking.Mocking.when; import static com.buildria.mocking.Mocking.verifyWhen; ``` ## Quick example ``` java public class SampleCodeTest { @Rule public Mocking mocking = new Mocking(); @Rule public TestNameRule testNameRule = new TestNameRule(); @Before public void setUp() throws Exception { RestAssured.port = mocking.getPort(); } @Test public void testReadMeSampleCode() { Person person = new Person("Bob", 20); // MockingTest when("/api/p/{id}"). withPathParam("id", 5). then(). withStatusCode(SC_201_CREATED). withContentType("application/json; charset=UTF-8"). withBody(person); // Rest-assured given(). pathParam("id", 5). accept("application/json"). contentType("application/json; charset=UTF-8"). body(person). when(). put("/api/p/{id}"). then(). statusCode(SC_201_CREATED). contentType("application/json; charset=UTF-8"). body("name", is("Bob")). body("old", is(20)); // MockingTest verifyWhen("/api/p/{id}"). withPut(). withPathParam("id", 5). then(). withAccept("application/json"). withContentType("application/json; charset=UTF-8"). withBody("name", is("Bob")). withBody("old", is(20)). withoutHeader("Referer"); } (snip) } ``` ## Maven instructions ``` xml <dependencies> <dependency> <groupId>com.buildria.mocking</groupId> <artifactId>mocking</artifactId> <version>0.4</version> <scope>test</scope> </dependency> </dependencies> <repositories> <repository> <id>buildria.com</id> <name>buildria.com Maven2 Repository</name> <url>http://ci.buildria.com/plugin/repository/everything/</url> </repository> </repositories> ``` TEST
# Mocking [](http://ci.buildria.com/job/mocking/) Mocking is a test framework which is inspired by [Restito](https://github.com/mkotsur/restito). Mocking provides a DSL to: * Mimic rest server behavior * Record HTTP calls to the server * Perform verification against happened calls * Automatic serialization ## Static import In order to use Mocking effectively, it's recommended to statically import methods from the following classes: ``` java import static com.buildria.mocking.Mocking.when; import static com.buildria.mocking.Mocking.verifyWhen; ``` ## Quick example ``` java public class SampleCodeTest { @Rule public Mocking mocking = new Mocking(); @Rule public TestNameRule testNameRule = new TestNameRule(); @Before public void setUp() throws Exception { RestAssured.port = mocking.getPort(); } @Test public void testReadMeSampleCode() { Person person = new Person("Bob", 20); // MockingTest when("/api/p/{id}"). withPathParam("id", 5). then(). withStatusCode(SC_201_CREATED). withContentType("application/json; charset=UTF-8"). withBody(person); // Rest-assured given(). pathParam("id", 5). accept("application/json"). contentType("application/json; charset=UTF-8"). body(person). when(). put("/api/p/{id}"). then(). statusCode(SC_201_CREATED). contentType("application/json; charset=UTF-8"). body("name", is("Bob")). body("old", is(20)); // MockingTest verifyWhen("/api/p/{id}"). withPut(). withPathParam("id", 5). then(). withAccept("application/json"). withContentType("application/json; charset=UTF-8"). withBody("name", is("Bob")). withBody("old", is(20)). withoutHeader("Referer"); } (snip) } ``` ## Maven instructions ``` xml <dependencies> <dependency> <groupId>com.buildria.mocking</groupId> <artifactId>mocking</artifactId> <version>0.4</version> <scope>test</scope> </dependency> </dependencies> <repositories> <repository> <id>buildria.com</id> <name>buildria.com Maven2 Repository</name> <url>http://ci.buildria.com/plugin/repository/everything/</url> </repository> </repositories> ```
Show line notes below