Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
public class DonateFixture {
private Library library;
private Title title;
private Member donor;
private EmailQueue queue;
private ArgumentCaptor<EmailAlert> alert;
private InterestedMemberSearch search;
public DonateFixture(){
search = new InterestedMemberSearchStub(
new String[]{
public void setDonor(String memberId){
donor = new Member();
public void setTitle(String name){
title = new Title(name);
public boolean libraryContains(){
return library.contains(title);
public int copyCount(){
return title.getCopyCount();
public int rewardPoints(){
return donor.getRewardPoints();
public String emailSubject(){
return alert.getValue().getSubject();
public String emailBody(){
return alert.getValue().getBody();
public String recipients(){
return alert.getValue().getRecipients();
public void donateMovieThatIsntInTheLibrary(){
setTitle("The Abyss");
assertEquals(1, copyCount());
assertEquals(10, rewardPoints());
assertEquals("Now available - The Abyss", emailSubject());
assertEquals("Dear member, just to let you know that The Abyss is now available to borrow",
private void donateTitle() {
queue = mock(EmailQueue.class);
alert = ArgumentCaptor.forClass(EmailAlert.class);
library = new Library(queue, search);
library .donate(title, donor);

jasongorman commented Jul 23, 2016

Example of a FitNesse fixture adapted to run as a JUnit test, too. Beware: order of inputs & outputs is important as to when to do set-up.

Screenshot of FitNesse Wiki page:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment