Recently we had a bug in our system that is caused by forgetting to assign a newly added class property in the copy constructor.
For example:
public class MyClass {
private Long companyId;
private Long classId;
private Double value; <= newly added
public MyClass(MyClass myClass) {
this.setCompanyId(myClass.getCompanyId());
this.setClassId(myClass.getClassId());
this.setValue(myClass.getValue()); <= we forget this line
}
I want to write a unit test that guarantees to catch the missing copy assignment when a new property is added. How should I proceed with this?