Trying to mock an instance creation:
//Class
final InformationSection infoSec = new InformationSection("123");
with
//Test
PowerMockito.suppress(MemberMatcher.constructorsDeclaredIn(InformationSection.class));
InformationSection infoSec = mock(InformationSection.class);
when(InformationSection.class).withArguments(Mockito.anyString()).thenReturn(infoSec);
The constructor of InformationSection
which I am trying to suppress is internally doing
Integer.parseInt("123")
to call another constructor of the same class with Integer argument and that is throwing NumberFormatException
:
java.lang.NumberFormatException: null
at java.lang.parseInt(Integer.java:615)
InformationSection.<init>(InformationSection.java:40)
So my confusion is if I am suppressing the constructor, why is it still doing that parsing?
I am referring to:
What does <init> signify in a Java exception?
Is this happening before suppressing the constructor?
Go to Source
Author: Ssk92