-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgraded remaining durations to use kotlin.time
- Loading branch information
Showing
11 changed files
with
201 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 20 additions & 16 deletions
36
kotlintest-core/src/commonMain/kotlin/io/kotlintest/TestResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
package io.kotlintest | ||
|
||
import kotlin.time.Duration | ||
import kotlin.time.ExperimentalTime | ||
|
||
@UseExperimental(ExperimentalTime::class) | ||
data class TestResult(val status: TestStatus, | ||
val error: Throwable?, | ||
val reason: String?, | ||
val durationMs: Long, | ||
val duration: Duration, | ||
val metaData: Map<String, Any?> = emptyMap()) { | ||
companion object { | ||
fun success(durationMs: Long) = TestResult(TestStatus.Success, null, null, durationMs) | ||
val Ignored = TestResult(TestStatus.Ignored, null, null, 0) | ||
fun failure(e: AssertionError, durationMs: Long) = TestResult(TestStatus.Failure, e, null, durationMs) | ||
fun error(t: Throwable, durationMs: Long) = TestResult(TestStatus.Error, t, null, durationMs) | ||
fun ignored(reason: String?) = TestResult(TestStatus.Ignored, null, reason, 0) | ||
} | ||
companion object { | ||
fun success(duration: Duration) = TestResult(TestStatus.Success, null, null, duration) | ||
val Ignored = TestResult(TestStatus.Ignored, null, null, Duration.ZERO) | ||
fun failure(e: AssertionError, duration: Duration) = TestResult(TestStatus.Failure, e, null, duration) | ||
fun error(t: Throwable, duration: Duration) = TestResult(TestStatus.Error, t, null, duration) | ||
fun ignored(reason: String?) = TestResult(TestStatus.Ignored, null, reason, Duration.ZERO) | ||
} | ||
} | ||
|
||
enum class TestStatus { | ||
// the test was skipped completely | ||
Ignored, | ||
// the test was successful | ||
Success, | ||
// the test failed because of some exception that was not an assertion error | ||
Error, | ||
// the test ran but an assertion failed | ||
Failure | ||
// the test was skipped completely | ||
Ignored, | ||
// the test was successful | ||
Success, | ||
// the test failed because of some exception that was not an assertion error | ||
Error, | ||
// the test ran but an assertion failed | ||
Failure | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.