Home>
@RunWith (PowerMockRunner.class)
public class test1 {
@InjectMocks
test1 target = new test ();
@Test
public void testCase01 () {
assertEquals ("777", target.encode (null));
}
}

After executing the above, java.lang.AssertionError: expected<777>but was
have become.

How can I return assertEquals ("777", target.encode (null));as the correct result instead of an error?
assertEquals Should I change this method?

  • Answer # 1

    java.lang.AssertionError: expected<777>but was

    Is the message that I expected "777" but returned null.

    Correct result for null

    If so

    assertEquals Should I change this method?

    You can use assertNull.