0

Code under test:

public class MyClass {
  public static void methodA() {
    methodB(x, y);  //x and y are some variables
  }

  public static void methodB(int x, ArrayList<String> y) {
    //do something
  }
}

Test Case:

    @Test
    public void testMethodA() {

        PowerMockito.stub(PowerMockito.method(MyClass.class, "methodB", Integer.class, ArrayList.class)).toReturn(null);

        MyClass.methodA();

        //TODO: verification
    }

How can I verify that methodB was called atleast once?

Anurag
  • 45
  • 7
  • 1
    I am not trying to be rude, but have you tried googling this? There's a ton of answers, e.g. https://stackoverflow.com/questions/34323909/verify-static-method-call-using-powermockito-1-6 – Igor Flakiewicz Nov 25 '21 at 16:34
  • `mockito-inline` with `Junit5` dismiss the use of `powermock*`. Try this -> https://stackoverflow.com/a/70108375/2096986 – Felipe Nov 27 '21 at 09:54
  • @Felipe , actually I am forced to use Junit 4. – Anurag Nov 27 '21 at 14:10

0 Answers0