Skip to content
Advertisement

Tag: powermockito

How to mock LocalDateTime.now() in java 8

Please, I am testing a functionality ABC that uses LocalDateTime.now(). In the methode ABC i’am comparing an entry date with the LocalDateTime.now() I want my test to be passed at any day so i have to mock the LocalDateTime.now() This is my test: I am using JAVA 8 the date shown in the console is always the real LacalDateTime not

Handle anonymous class with Generics in Mockito

I am trying to write unit test using Powermockito for following method – I have written test method as – When I run this test I always get it failed saying – It looks like stub is not working as I always get “null” for this line – Is it because anonymous instantiation of TypeReference class? Answer Yes, it’s because

Advertisement