我正在使用我的Ubuntu 14.04 LTS进行构建但是我得到以下内容:
Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/videovixx
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url https://bitbucket.org/mdennis10/videovixx.git # timeout=10
Fetching upstream changes from https://bitbucket.org/mdennis10/videovixx.git
> /usr/bin/git --version # timeout=10
using .gitcredentials to set credentials
> /usr/bin/git config --local credential.helper store -- file=/tmp/git6236060328558794078.credentials # timeout=10
> /usr/bin/git fetch --tags --progress https://bitbucket.org/mdennis10/videovixx.git +refs/heads/*:refs/remotes/origin/*
> /usr/bin/git config --local --remove-section credential # timeout=10
> /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> /usr/bin/git rev-parse …Run Code Online (Sandbox Code Playgroud) 如果我们想在类型上测试扩展函数,我们可以创建这种类型的实例,调用函数并检查返回的值.但是如何测试类中定义的扩展函数呢?
abstract class AbstractClass<T> {
fun doStuff(): T = "Hello".foo()
abstract fun String.foo(): T
}
class SubClass1: AbstractClass<Int>() {
override fun String.foo(): Int = 1
}
class SubClass2: AbstractClass<Boolean>() {
override fun String.foo(): Boolean = true
}
Run Code Online (Sandbox Code Playgroud)
我们如何测试方法的逻辑foo()中类SubClass1和SubClass2?它甚至可能吗?
我知道我可以改变设计来测试它.我有两种可能性:
不要使用扩展功能.¯\ _(ツ)_ /¯
abstract class AbstractClass<T> {
fun doStuff(): T = foo("Hello")
abstract fun foo(string: String): T
}
class SubClass1: AbstractClass<Int>() {
override fun foo(string: String): Int = 1
}
Run Code Online (Sandbox Code Playgroud)
然后我们可以创建一个对象SubClass1,调用foo()并检查返回的值. …