Skip to content

Instantly share code, notes, and snippets.

@dgroup
Last active August 24, 2020 13:55
Show Gist options
  • Save dgroup/2a9401ccf63dbfc2a63eb8b4d1c1e526 to your computer and use it in GitHub Desktop.
Save dgroup/2a9401ccf63dbfc2a63eb8b4d1c1e526 to your computer and use it in GitHub Desktop.

Option 1

import java.util.Date;

import my.domain.FakeOrder;
import my.domain.Price;
import my.domain.OrderWith;
import my.domain.ItemsTotal;
import my.domain.MyTypicalJavaService;

import org.hamcrest.MatcherAssert;

public class NewLineActivationTest {
    @Test
    public void priceFound(){
      MatcherAssert.assertThat(
        "Order with two items of something has price 50 USD",
        new MyTypicalJavaService().process(
          new FakeOrder(/* order properties */)    
        ),
        new OrderWith(
          new Price(50, "USD"),
          new ItemsTotal(2)
        )
      );
    }
}

Option 2

import my.domain.FakeOrder;
import my.domain.MyTypicalJavaService;
import my.domain.OrderAssert;

public class NewLineActivationTest {
    @Test
    public void priceFound(){
      OrderAssert.assertThat(
        new MyTypicalJavaService().process(
          new FakeOrder(/* order properties */)    
        )
      )
      .describeAs("Order with two items of something has price 50 USD")
      .withPrice(50, "USD")
      .itemsTotal(2);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment