Minor: make test output less verbose

This commit is contained in:
Ilya Gorbunov
2016-06-20 18:15:58 +03:00
parent 157ed3f8c1
commit 919c099a95
3 changed files with 16 additions and 5 deletions
+13 -2
View File
@@ -6,6 +6,7 @@ import test.collections.assertArrayNotSameButEquals
import org.junit.Test as test
import java.io.PrintWriter
import java.io.*
import java.nio.charset.Charset
class ExceptionJVMTest {
@@ -24,7 +25,7 @@ class ExceptionJVMTest {
val buffer = StringWriter()
val writer = PrintWriter(buffer)
t.printStackTrace(writer)
println(buffer)
comparePrintedThrowableResult(t, buffer.buffer)
}
fun assertPrintStackTraceStream(t: Throwable) {
@@ -40,7 +41,17 @@ class ExceptionJVMTest {
}
val bytes = assertNotNull(byteBuffer.toByteArray())
assertTrue(bytes.size > 10)
val content = bytes.toString(Charset.defaultCharset())
comparePrintedThrowableResult(t, content)
}
private fun comparePrintedThrowableResult(throwable: Throwable, printedThrowable: CharSequence) {
val stackTrace = throwable.stackTrace
val lines = printedThrowable.lines()
assertEquals(throwable.toString(), lines[0])
stackTrace.forEachIndexed { index, frame ->
assertTrue(lines.any { frame.toString() in it }, "frame at index $index is not found in the printed message")
}
}
@test fun changeStackTrace() {
@@ -15,12 +15,12 @@ class TimerTest {
val task = timer.scheduleAtFixedRate(1000, 100) {
val current = counter.incrementAndGet()
println("Timer fired at $current")
// println("Timer fired at $current")
}
Thread.sleep(1500)
task.cancel()
val value = counter.get()
assertTrue(value > 4, "current counter is $value")
assertTrue(value > 4, "Expected to fire at least 4 times, but was $value")
}
}
+1 -1
View File
@@ -157,7 +157,7 @@ class FilesTest {
fun assertFailsRelativeTo(file: File, base: File) {
val e = assertFailsWith<IllegalArgumentException>("file: $file, base: $base") { file.relativeTo(base) }
println(e.message)
// println(e.message)
}
val allFiles = listOf(absolute, relative) + if (isBackslashSeparator) listOf(networkShare1, networkShare2) else emptyList()