-
-
Notifications
You must be signed in to change notification settings - Fork 378
Closed
Description
There are a few classes that it is generally a bad idea to mock: trying to mock them is usually a code smell indicating that a test is not testing the correct part of the application, and mocking them usually leads to problems.
Some of these are:
System
- Collections (particularly
HashMap
) - Data classes, and in general value objects
- Classes that deal with I/O, like
File
orPath
(you should be wrapping them in a layer that only deals with I/O rather than mixing it with business logic)
Mockk should at least log a warning when trying to mock one of these classes, but ideally it should also have a configuration flag that disables mocking them altogether and has it throw an exception when a user tries to.
We could maybe even make the list of non-mockable classes configurable.
SimonMarquis, AlexKrupa and IRus