You need to replay the mock
CountMetric countMetric = new CountMetricStub("count");
expect(metricManager.getOrCreateCountMetric(anyObject(String.class))).andStubReturn(countMetric);
EasyMock.replay(metricManager); //Add this line
CountMetric metric = metricManager.getOrCreateCountMetric("ASDF");
assertNotNull(metric);
Currently, the metricManager
is still in record mode which means any calls to its methods just perform default behaviour.
If you have a call to EasyMock.verify()
in there too (without the call to replay()
) EasyMock tells you that you can't call verify while in record mode.