Created
September 6, 2011 08:59
-
-
Save akiellor/1197027 to your computer and use it in GitHub Desktop.
RSpec Style Runner for JUnit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(BehaviourRunner.class) | |
@ItBehavesLike(ListBehaviours.class) | |
public class ArrayListTest { | |
@Subject ArrayList<String> list(){ | |
return new ArrayList<String>(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(BehaviourRunner.class) | |
@ItBehavesLike(ListBehaviours.class) | |
public class LinkedListTest { | |
@Subject LinkedList<String> list(){ | |
return new LinkedList<String>(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ListBehaviours { | |
@It void shouldAddElements(List<String> subject){ | |
assertThat(subject, hasSize(0)); | |
list.add("An element"); | |
assertThat(subject, hasSize(1)); | |
} | |
@It void shouldRemoveElements(List<String> subject){ | |
assertThat(subject, hasSize(0)); | |
list.add("An element"); | |
assertThat(subject, hasSize(1)); | |
assertThat(subject, contains("An element")); | |
list.remove(0); | |
assertThat(subject, hasSize(0)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(BehaviourRunner.class) | |
public class StringTest { | |
@Subject String string(){ return "Some string"; } | |
@It void shouldStartWithSome(String subject){ | |
assertThat(subject, startsWith("Some")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment