Skip to content

Instantly share code, notes, and snippets.

@mohakhan
mohakhan / night-before-opsmas.txt
Created January 9, 2023 22:58 — forked from am2antun/night-before-opsmas.txt
Twas the night before Opsmas..
'Twas the night before Christmas, when all through the racks
Not a server was alerting, not even Compaqs.
The backups were written to tapes with care
In hopes that later the data would be there.
The machines were nestled all snug in their sleds
Whilst visions of vengeance danced in their heads;
And oncall in his three-wolf and I in my rack.
Had just settled down for some syn and some ack.
@mohakhan
mohakhan / MockAndSpy.java
Created January 13, 2021 17:32 — forked from MichalAdorno/MockAndSpy.java
@SpyBean vs @MockBean /spies vs mocks in programmatic testing
/*
@MockBean //or Mockito's @Mock
- it mocks the object and all its methods with do nothing and their result value will be null,
- use for example: when(...) methods to create mocked method behaviour
- use when you want to completely get rid of the object's normal behaviour
- caution: unmocked methods won't work -> can result in a RuntimeException during tests (@SpyBean is a remedy here apart from wider mocking)
@SpyBean //or Mockito's @Spy
- an object will behave like an @Autowired object
- all its methods will actually works, but we can define some custom behavior for its methods
- use doReturn(...) / doNothing(...) to add custom (mocked) method behaviour