File: StaticMockMember.md

package info (click to toggle)
error-prone-java 2.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 23,204 kB
  • sloc: java: 222,992; xml: 1,319; sh: 25; makefile: 7
file content (9 lines) | stat: -rw-r--r-- 547 bytes parent folder | download
1
2
3
4
5
6
7
8
9
Making a `@Mock` instance `static` will share the state across tests and can
make them order dependent and/or unclear to reader/maintainer. Removing
`static`, will ensure fresh mock instances are used for each tests.

Additionally, if the `@Mock` instance is marked as `static` to make it
serializable, there is a cleaner way to do it :
https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#serilization_across_classloader
and
https://javadoc.io/static/org.mockito/mockito-core/3.3.3/org/mockito/Mock.html#serializable--