What Are Mock Objects?For a good overview of Mock Objects, please read: https://stackoverflow.com/questions/3622455/what-is-the-purpose-of-mock-objectsWhy Do We Need Mock Data In QBO3?The use case that ultimately prompted this functionality is the need to test ImportForms that rely on 3rd party data, without depending on the 3rd party. Example:
Mock data allows us to define test data, intercept an outgoing Request, and return the test data. Code SampleMock data is only available in the context of Jasmine tests, or Theme.ashx/Specs. In our tests, we have to define test data in a jasmine.mockData object.
Abstract example: jasmine.mockData = { ClassName: { Method: { TestItem1: TestValue1 } } }; If one needed to test against a Fiserv entry in which the USState = 'CA' and LienPosition='002', the mock data object would be: In this case, any call to Loan/Fiserv would return the test data defined above. This is, in a rough way, an instantiation of the Dependency Injection pattern, which is critical for robust testing: http://jasonpolites.github.io/tao-of-testing/ch3-1.1.html |