0

I am trying to verify my 3 methods that I am testing, only that I use my PowerMockito.verifyStatic in 3 different test methods and apparently that is the problem, that it does not let me test the 3 methods, instead if in a single test method, I verify my 3 methods that I want to test, if it runs well.

And what I want is to have test per method that I am going to test, I add code from my 3 test methods, in these 3 tests what I basically want to check is that the date is formatted correctly:

@InjectMocks
FormatsDates formatsDatesMock;

@Test
public void testFileAEDateFormat() throws Exception {
    String parameterDateMock = "20230421";
    Whitebox.invokeMethod(formatsDatesMock, "fileAEDateFormat", parameterDateMock);
    PowerMockito.verifyStatic(FormatsDates.class, atLeastOnce());
}

@Test
public void testDateFormatQuery() throws Exception {
    String parameterDateMock = "20230420";
    Whitebox.invokeMethod(formatsDatesMock, "dateFormatQuery", parameterDateMock);
    PowerMockito.verifyStatic(FormatsDates.class, atLeastOnce());
}

@Test
public void testFilePEDateFormat() throws Exception {
    String parameterDateMock = "19/04/2023";
    Whitebox.invokeMethod(formatsDatesMock, "filePEDateFormat", parameterDateMock);
    PowerMockito.verifyStatic(FormatsDates.class, atLeastOnce());
}

0 Answers0