سؤال

I am writing a unit test for a function that calls a getter on my object. The getter should return an array, but I get an exception thrown:

Error: No Expectation defined for Invocation:[FloxyInvocation invocationType=GETTER name="getterName" arguments=[]]

I mocked my getter with:

mock(object).getter("getterName").returns(new Array()).once();

My getter is defined in the object interface:

function get getterName():Array;

Do I need to rewrite the getter function or my mock statement?

هل كانت مفيدة؟

المحلول

I was mocking the interface of the object instead of and object of the class that implements the interface.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top