- . , registerNewRecord (, ). , new, . , / , .
, registerNewRecord() , , Record. Record - registerNewRecord() . , Record, .
MyClassStub extends MyClass {
Record registerNewRecord() {
return recordMock;
}
}
MyClass objectToTest = new MyClassStub();
public void testSomeMethod() {
objectToTest.someMethod();
}
As a positive side effect, you will find that your test only breaks when something is wrong with the code in the method you are testing, and never breaks if the problem is with the write constructor or registerNewRecord. However, you will want to write a second test for the method registerNewRecord()to make sure that it works correctly.
source
share