java JMockit mock enumeration method

1 Gradle introduces JMockit, add the following content in the build.gradle file, it needs to be placed before junit
implementation 'org.jmockit:jmockit:1.39'
 
2 File ArchiveSpaceManagerImplTest.java

@Mocked
FormatType formatType32;
 
3 Use the following code in the code, the getSize method of the module enumeration returns a specific value
new Expectations(formatType32) {
{
formatType32.getSize();
result = 32L * 1024 * 1024 * 1024;
}
};
 
4 Comparison of functions of various mock tools, among which JMockit supports the most features.
https://blog.csdn.net/yasi_xi/article/details/24642517

Guess you like

Origin www.cnblogs.com/longchang/p/12707233.html