Android Studio - with Junit 4.12 “!!! JUnit version 3.8 or later expected:”

前端 未结 14 1558
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 15:50

Tried out the suggestions on this post, but I still get the error:

!!! JUnit version 3.8 or later expected:

java.lang.RuntimeException: Stub!
    at junit.r         


        
14条回答
  •  春和景丽
    2021-01-07 16:48

    The below fix is a work around and a repetitive task you need to perform on every new class that you create. I have used Gradle for my project on Android Studio.

    Step 1: Go to Run-> Edit Configurations Option

    Step 2: For each JUnit test configuration, change and add the below into the fields: a) JRE: Default is selected. Change it to the JRE version you have on your PC which you get as an option in the drop-down. As of today, its 1.8 b) Before launch field: Click on '+', select your module and add task as "clean compileTestJava". Move it to top in the list JUnit test configuration

    Step 3: Apply Changes and now run your java class.

提交回复
热议问题