最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - Classess or Objects inside main source set, can not be accessed by test (unit test) source set - Stack Overflow

programmeradmin0浏览0评论

It is a simple unit test, with only a single object and its corresponding unit test class. The object is in main/java/com/example/simpleunittest/Validator.kt and the test class is in test/java/com/example/simpleunittest/ValidatorTest.kt

Validator.kt below:

package com.example.simpleunittest

object Validator {
    fun sendboolean(param : Int) : Boolean {
        if (param == 0) {
            return false
        } else if (param == 1) {
            return false
        }
        return true
    }
}

ValidatorTest.kt below:

package com.example.simpleunittest

import .junit.Assert.*
import .junit.Test
import .junit.runner.RunWith
import .junit.runners.JUnit4

@RunWith(JUnit4::class)
class ValidatorTest{

    @Test
    fun zero_returns_false() {
        val validate = Validator
        assertFalse(validate.sendboolean(0))
    }

}

and the error is:

java.lang.NoClassDefFoundError: com/example/simpleunittest/Validator

Please help why "Validator.kt" can not be found by "ValidatorTest.kt", and test fails.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论