Unittest to verify that static method is called

.. using PowerMock, Mockito, TestNG

In example the class under test (cut) has a method showErrorMessage(msg). This method will call the static method JOptionPane.showMessageDialog(...) to show a error message.

I wrote a unittest to

  1. mock the showMessageDialog call - because otherwise the test will fail with an java.lang.VerifyError (UIManager is not initialized)
  2. verify that showMessageDialog is called + with the right parameter

Keine Kommentare

Kommentar veröffentlichen