- create service instance for testing
- prepare request
- send request and receive response
- validate response
@Test
public void shouldNotSellIfInhibitRule() throws Exception {
// given
SellDataRetriever retriever = createRetrieverWithFixedBookResponse("sell_inhibit_rule_rsp.xml");
SellRQ anyValidRequest = createMinimalValidSellRequest();
// when
SellRS response = retriever.sell(anyValidRequest);
// then
assertEquals(ResponseStatus.FAILURE, response.getResponseStatus());
}or@Test
public void shouldNotSellIfInhibitRule() throws Exception {
// given
SellDataRetriever retriever = createRetrieverWithFixedBookResponse("sell_inhibit_rule_rsp.xml");
// when
SellRQ anyValidRequest = createMinimalValidSellRequest();
SellRS response = retriever.sell(anyValidRequest);
// then
assertEquals(ResponseStatus.FAILURE, response.getResponseStatus());
} Although I haven’t found the right answer yet here's some hint:http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd
GIVEN should set the SUT to some fixed state. WHEN should change that state. Based on these two I think that preparing the request is part of the code responsible for state transition and thus it belongs to WHEN. In my opinion the second solution is better :-)
No comments:
Post a Comment