Stubbing private methods of SUT with sinon

977 views
Skip to first unread message

hellboy

unread,
Apr 10, 2015, 5:37:43 AM4/10/15
to sin...@googlegroups.com
I should test public method that calls private method.

As I mentioned this private method

- should not be tested yet
- should not be called, but replaced with stub
- should be extracted to new object and made public. Now tests can be added

But I am not sure, if I SHOULD make this refactoring before, and mock this extracted public method, or I can still stub private method. Refactoring is not necessary to write test properly.

Message has been deleted

hellboy

unread,
Jun 25, 2015, 7:33:12 AM6/25/15
to sin...@googlegroups.com
Private functions can be also be tested and stubbed using rewire as folows

Comments are welcome.

See also Rewire-Expose Private in Tests
Reply all
Reply to author
Forward
0 new messages