EasyMock - CreateNiceMock -


a straightforward question regarding easymock. read bunch of resources not sure missing:

the following snippet creating unit test using test-ng:

@test(groups = "unit") public class schooltesteasymock {      @test     public void test1() {         school mockschool = easymock.createnicemock(school.class);         easymock.replay(mockschool);         system.out.println(mockschool.getschoolnumber());     } } 

let's assume school class has simple getter 'getschoolnumber' returns integer.

the snippet above printing 'null' console. since i'm creating 'nice' mock shouldn't 'getschoolnumber' return default value of 0? missing while creating nice mock?

from documentation:

if "nice" mock object default allows method calls , returns appropriate empty values (0, null or false), use nicemock() instead.

as integer object, default value null. if change return type of method int, value 0 expected.


Comments