ruslan-kurchenko / asserta

First (really???) Salesforce Apex assertions library (actually, a project template at this point ;)
3 stars 0 forks source link

Mocking #3

Open olexandrKrykun opened 3 years ago

olexandrKrykun commented 3 years ago

should mocking functionality be a part of this project? Does it make sense to create a single library with all testing means combined together? What is the difference between spies mocks, stubs Fakes, dummies? Mock vs Spy.

ruslan-kurchenko commented 3 years ago

@olexandrKrykun I don't think so. asserta is a library to run assertions. If we would plan to introduce a mocking library - it, potentially, could be on top of asserta, we could discuss it.

I would divide all test doubles into two sections: mocks(mock, spy) and stubs(stub, dummy, fake)

Mocks: emulate the behaviour of dependency and check if interactions from the system under test are correct (Unit of Work) Stubs: emulate incoming interactions from the system under test to its dependencies to get input data (Selectors)

olexandrKrykun commented 3 years ago

@ruslan-kurchenko I would divide mock and spy as well. looking at mockito implementation spy uses real object under the hood and change the behavior only for one specific method. I was thinking that we can pass real object to the stub api and delegate calls to real object for all methods except those ones that we specified specific behaviour for. Again looking at mockito i can't find obvious differences between mock and stub. The only one is that mock should check the behavior but stub just overrides the behaviour. In other words tests with mocks should contain verify methods. https://www.infoworld.com/article/2074508/mocks-and-stubs---understanding-test-doubles-with-mockito.html