vendredi 15 janvier 2016

Uses for PowerMock's replay() and reset() methods

I recently encountered some code containing PowerMock's replay() and reset() methods. What is the use and best practice for using these functions? I've tried to look for proper documentation here, but it's not that clear.

I've attached a code snippet where it's been used:

    @Test
    public void methodTest() {
    Map<String, Object> token = new HashMap<String, Object>();
    tokenMap.put(Token.value1, Integer.valueOf(1234));
    tokenMap.put(Token.value2, "string");
    reset(cacheMock);
    expect(cacheMock.retreiveObject((Context) EasyMock.anyObject(),eq("token"))).andReturn(tokenMap);
    replay(cacheMock);

    assertEquals("1234", token.methodToBeTested(context));
    }

Aucun commentaire:

Enregistrer un commentaire