Skip to content

Instantly share code, notes, and snippets.

@oscarlvp oscarlvp/VList.java
Created Dec 21, 2018

Embed
What would you like to do?
Introductory example of a pseudo-tested method
class VList {
private List elements;
private int version;
public void add(Object item) {
elements.add(item);
incrementVersion();
}
private void incrementVersion() { // This method is pseudo-tested
version++;
}
public int size() {
return elements.size();
}
}
class VListTest {
@Test
public void testAdd() {
VList l = new VList();
l.add(1); // This line touches the add and the incrementVersion methods
assertEquals(l.size(), 1); // This line touches the size method
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.