lundi 4 juillet 2016

EasyMock - override an object creation

How can I override an object creation inside a method?

public class ClassToTest {
    public Object testMethod() {
        ... code ...
        Object result;
        try {
            result = new ClassToMock(someParam).execute();
        } catch (Exception e) {
            // handle error
        }

        return result;
    }
}

How can my test override the "execute" method of ClassToMock? I will be happy for code examples with EasyMock.

Aucun commentaire:

Enregistrer un commentaire