简单的计算器,使用带Spek的KOTLIN进行单元测试(退出代码-1)

我对android开发很陌生,最近做了我的第一个项目。 这只是一个加法,减法,乘法和除法的基本计算器。

我现在试图做单元测试来测试我的计算器的功能,但我收到了这个输出(如下所示)。 我不知道是什么导致了这种情况发生。 请帮忙

输出: 在这里输入图像描述

FunctionsTest.kt:

@RunWith(JUnitPlatform::class) class FunctionsTest : Spek({ given("a calculator") { on("adding the first number to the second number") { val sum = Functions.addFunction(2.0, 3.0) it("should return the result of adding the first number to the second number") { assertEquals(5, sum) } } on("subtracting the second number from the first number") { val sub = Functions.minusFunction(5.0,2.0) it("should return the value of subtracting the second number from the first number") { assertEquals(3, sub) } } on("Multiplying the first number and the second number") { val mul = Functions.multiFunction(5.0,2.0) it("should return the value of multiplying the first and second number") { assertEquals(10, mul) } } on("Dividing the second number from the first number") { val div = Functions.divFunction(9.0,3.0) it("should return the value of dividing the second number from the first number") { assertEquals(3, div) } } } }) 

Gradle构建:

 apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 25 buildToolsVersion "25.0.3" defaultConfig { applicationId "com.example.zhiwen.calculator" minSdkVersion 21 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" androidTestCompile 'com.android.support:support-annotations:25.3.1' androidTestCompile 'com.android.support.test:runner:0.5' testCompile"org.jetbrains.spek:spek-api:1.1.2" testCompile"org.jetbrains.spek:spek-junit-platform-engine:1.1.2" testCompile"org.junit.platform:junit-platform-runner:1.0.0-M4" configurations.all { resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } dependencies { testCompile "com.nhaarman:mockito-kotlin:1.3.0" } } repositories { maven { url "http://dl.bintray.com/jetbrains/spek" } mavenCentral() }