我正在使用带有gradle的javadoc doclet,所以我需要使用package tools.jar,它位于jdk的lib文件夹中(在我的例子中为1.6.0_26).
重点是gradle没有自动获取它,所以我将该工具包添加到我的libs文件夹,然后将其添加到dependencies.gradle.
现在我想直接从我的JDK home转到我的dependencies.gradle.有没有办法做到这一点?我在我的dependencies.gradle中尝试了下一个:
compile files("${System.properties['java.home']}/lib/tools.jar")
Run Code Online (Sandbox Code Playgroud)
但它在编译时没有找到它.
尝试在AS上运行检测测试.
坚持这个错误:
java.lang.IllegalStateException:无法在java.lang.reflect.Proxy上的org.mockito.internal.configuration.plugins.PluginLoader $ 1.invoke(PluginLoader.java:66)初始化插件:interface org.mockito.plugins.MockMaker.在$ Proxy4.isTypeMockable(未知来源)调用(Proxy.java:393)
ExampleInstrumentedTest.java
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Mock
Context context;
@Before
public void init(){
MockitoAnnotations.initMocks(this);
}
@Test
public void testDisabledFlag() {
ChanceValidator chanceValidator = new ChanceValidator(context);
Validator.ValidationResult result = chanceValidator.validate(2);
assertEquals(result, Validator.ValidationResult.NO_ERROR);
}
}
Run Code Online (Sandbox Code Playgroud)
的build.gradle
apply plugin: 'com.android.application'
android{
..
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// Unit testing dependencies
testCompile 'junit:junit:4.12'
// Set this dependency if you want to use …Run Code Online (Sandbox Code Playgroud) 我一直在将一个项目从 Java 8 迁移到 Java 12。除了单元测试之外,一切都很顺利。当我使用 Maven 编译和启动测试时,许多测试失败并显示以下消息:
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
at com.tetratech.csoft.ui.jfx.AppContextTest.<init>(AppContextTest.java:22)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in java.lang.CompoundEnumeration@35fd987b
Caused by: org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker. (This mock maker is not supported on Android.)
Java : 12
JVM vendor name : Oracle Corporation
JVM vendor version : 12+33
JVM name : OpenJDK 64-Bit Server VM
JVM version : 12+33
JVM info : mixed mode, …Run Code Online (Sandbox Code Playgroud) 我正面临 JUnit jar 兼容性问题。最初,当我创建我的 JUnit 类时,下面是主要的 jar 版本。
springframework.boot.version 1.3.0.RELEASE
Mock - mockito-core-1.10.19.jar
Power mockito - powermock-module-junit4-1.6.4.jar
powermock-api-mockito-1.6.4.jar
Run Code Online (Sandbox Code Playgroud)
现在我们已经将 spring boot 版本升级到 2.0.0.RELEASE 并且 maven build 正在下降并出现以下错误
Tests in error:
initializationError(com.amit.Test.TestStudent): org/mockito/cglib/proxy/Enhancer
testAddress(com.amit.test.TestAddressProcess): Could not initialize plugin: interface org.mockito.plugins.MockMaker
Run Code Online (Sandbox Code Playgroud)
我尝试了以下答案并将 powermock-api-mockito 更改为 powermock-api-mockito2 无法初始化插件:接口 org.mockito.plugins.MockMaker
但低于错误
testAddress((com.amit.test.TestAddressProcess): Invoking the beforeTestMethod method on PowerMock test listener org.powermock.api.extension.listener.AnnotationEnabler@22277482 failed.
Run Code Online (Sandbox Code Playgroud)
更新的版本是
springframework.boot.version 2.0.0.RELEASE
Mock - mockito-core-2.15.0.jar
Power mockito - powermock-module-junit4-2.0.0.jar
powermock-api-mockito-2.0.0.jar
Run Code Online (Sandbox Code Playgroud)
如果其他人遇到与 jar 版本相同的问题,请提供帮助
完整的堆栈跟踪
java.lang.RuntimeException: Invoking the beforeTestMethod method on PowerMock test …Run Code Online (Sandbox Code Playgroud) java ×3
mockito ×3
gradle ×2
junit ×2
android ×1
build ×1
groovy ×1
powermockito ×1
spring-boot ×1
unit-testing ×1