You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am facing the org.mockito.exceptions.misusing.InvalidUseOfMatchersException exception while doing powermockito on following static method
public class ShellCommandUtil {
public static ArrayList executeShellCommand(String[] shellcmd) {
ArrayList output = new ArrayList();
//remove the actual logic of sending shellcommand to the system and getting the result
return output;
}}
TestMethod written is defined below
@RunWith(PowerMockRunner.class)
@PrepareForTest(ShellCommandUtil.class)
public class ShellDataTest{ @test
public void testExecuteShellCommand() {
ArrayList resultData = new ArrayList();
resultData.add("data1");
resultData.add("data2");
PowerMockito.mockStatic(ShellCommandUtil.class);
PowerMockito.when(ShellCommandUtil.executeShellCommand(Mockito.any(String[].class))).thenReturn(resultData);
}
}
Can you please help what is defined wrong here in this line
The text was updated successfully, but these errors were encountered:
rajmaria
changed the title
WrongTypeOfReturnValue exception using PowerMockito to call static method with String array argument
InvalidUseOfMatchersException exception using PowerMockito to call static method with String array argument
Sep 8, 2016
Hi there,
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Misplaced argument matcher detected here:
I am facing the org.mockito.exceptions.misusing.InvalidUseOfMatchersException exception while doing powermockito on following static method
public class ShellCommandUtil {
public static ArrayList executeShellCommand(String[] shellcmd) {
ArrayList output = new ArrayList();
//remove the actual logic of sending shellcommand to the system and getting the result
return output;
}}
TestMethod written is defined below
@RunWith(PowerMockRunner.class)
@PrepareForTest(ShellCommandUtil.class)
public class ShellDataTest{
@test
public void testExecuteShellCommand() {
ArrayList resultData = new ArrayList();
resultData.add("data1");
resultData.add("data2");
PowerMockito.mockStatic(ShellCommandUtil.class);
PowerMockito.when(ShellCommandUtil.executeShellCommand(Mockito.any(String[].class))).thenReturn(resultData);
}
}
Can you please help what is defined wrong here in this line
PowerMockito.when(ShellCommandUtil.executeShellCommand(Mockito.any(String[].class))).thenReturn(resultData);
In pom.xml, I have added the following dependency
org.powermock powermock-mockito-release-full 1.6.4 pomThe text was updated successfully, but these errors were encountered: