Moved failsWith to TestJVM.
This commit is contained in:
@@ -85,19 +85,6 @@ public fun fails(block: ()-> Unit): Throwable? {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Asserts that a block fails with a specific exception being thrown */
|
|
||||||
public fun <T: Throwable> failsWith(block: ()-> Any): T {
|
|
||||||
try {
|
|
||||||
block()
|
|
||||||
asserter.fail("Expected an exception to be thrown")
|
|
||||||
throw IllegalStateException("Should have failed")
|
|
||||||
} catch (e: T) {
|
|
||||||
//println("Caught expected exception: $e")
|
|
||||||
// OK
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A plugin for performing assertions which can reuse JUnit or TestNG
|
* A plugin for performing assertions which can reuse JUnit or TestNG
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,6 +2,19 @@ package kotlin.test
|
|||||||
|
|
||||||
import java.util.ServiceLoader
|
import java.util.ServiceLoader
|
||||||
|
|
||||||
|
/** Asserts that a block fails with a specific exception being thrown */
|
||||||
|
public fun <T: Throwable> failsWith(block: ()-> Any): T {
|
||||||
|
try {
|
||||||
|
block()
|
||||||
|
asserter.fail("Expected an exception to be thrown")
|
||||||
|
throw IllegalStateException("Should have failed")
|
||||||
|
} catch (e: T) {
|
||||||
|
//println("Caught expected exception: $e")
|
||||||
|
// OK
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comments out a block of test code until it is implemented while keeping a link to the code
|
* Comments out a block of test code until it is implemented while keeping a link to the code
|
||||||
* to implement in your unit test output
|
* to implement in your unit test output
|
||||||
|
|||||||
Reference in New Issue
Block a user