log
Logs a value in the test output.
Example
test("My test") {
val testUser = log(createTestUser())
// …
}Content copied to clipboard
» Logged ‘User(username=Bob, …)’Content copied to clipboard
This function is especially useful if you use Power Assert, as it allows displaying intermediary values of a complex expression.
To enable Power Assert, follow these steps then add:
powerAssert {
functions = listOf(
// …Add any other function you want to instrument…
"opensavvy.prepared.suite.assertions.log",
)
}Content copied to clipboard
Then, in your tests:
test("My test") {
log(12 + 5)
}Content copied to clipboard
» Logged ‘17’
log(12 + 5)
|
17Content copied to clipboard
You can use this function to get more context about complex expressions when a test fails.
Logs a value in the test output, with some additionalInfo.
Example
test("My test") {
val testUser = log(createTestUser()) { "Created test user" }
// …
}Content copied to clipboard
» Logged ‘User(username=Bob, …)’
Created test userContent copied to clipboard
This function is especially useful if you use Power Assert, as it allows displaying intermediary values of a complex expression.
To enable Power Assert, follow these steps then add:
powerAssert {
functions = listOf(
// …Add any other function you want to instrument…
"opensavvy.prepared.suite.assertions.log",
)
}Content copied to clipboard
Then, in your tests:
test("My test") {
log(12 + 5) { "Important intermediary result" }
}Content copied to clipboard
» Logged ‘17’
Important intermediary result
log(12 + 5)
|
17Content copied to clipboard
You can use this function to get more context about complex expressions when a test fails.
Parameters
additionalInfo
A lambda that generates a String that will be printed alongside the message.