jeudi 2 novembre 2017

How to rewrite removed "forEachInvocation" jmockit?

I have to upgrade from jmockit v0.999.15 to jmockit v1.33 and I am having issues rewriting a test which is using "forEachInvocation"

request.addParam(anyString, anyString); minTimes = 1; maxTimes = 10; 
forEachInvocation = new Object() {
     void validate(String someName, String someValue) {
            if(Utils.XML.equals(someName)) {
                assertTrue("incorrect value",someValue.contains("This is a test")); 
            } 
     } 
};

The above piece of code is part of Expectations.

In jmockit website the following is mentioned, but I am not sure how to rewrite it:

"Version 1.7: Removed the forEachInvocation field, which was deprecated in release 1.6. Existing tests using it should instead take advantage of the withCapture() and withCapture(List) methods, or convert the handler object to a Delegate object assigned to the result field (in the case of a recorded expectation)."

Aucun commentaire:

Enregistrer un commentaire