I have a class that uses XStream and is used as a transfer format for my application. I am writing tests for other classes that map this transfer format to and from a different messaging standard. I would like to ensure that all getters on my class are called within a test to ensure that if a new field is added, my test properly checks for it.
A rough outline of the XStream class
@XStreamAlias("thing")
public class Thing implements Serializable {
private int id;
private int someField;
public int getId(){ ... }
public int someField() { ... }
}
So now if I update that class to be:
@XStreamAlias("thing")
public class Thing implements Serializable {
private int id;
private int someField;
private String newField;
public int getId(){ ... }
public int getSomeField() { ... }
public String getNewField(){ ... }
}
I would want my test to fail because the old tests are not calling getNewField()
.
The goal is to ensure that if new getters are added, that we have some way of ensuring that the tests check them.
Ideally, this would be contained entirely in the test and not require modifying the underlying Thing class.
Any ideas? Thanks for looking!