dimanche 31 décembre 2017

when using jmockit, how to batch mock classes by special class and do inverse

In the spring environment using jmockit, I usually want to test a class that needs to mock many other many classes (which this class dependencies).

E.g: There are now Class1, Class2, ,, Class20.

Class1 depends on Class2, Class3 ,,, Class20 (via spring ioc).

I want to test Class1, need mock Class2, Class3 ,,, Class20 all, it is to much trouble.

How to write only once code can mock Class2, Class3 ,,, Class20.

The function I expect is this:

@Mocked (excludeClasses = {Class1}) (excludeClasses expect is a variable paramter)

@Test

public void methodOfClass1 () {

}

Aucun commentaire:

Enregistrer un commentaire