sqlState
fun <T : SQLException> Expect<T>.sqlState(assertionCreator: Expect<String>.() -> Unit): Expect<T>(source)
Expects that the result of calling getSQLState() on the subject of this expectation holds all assertions the given assertionCreator creates for it and returns an Expect for the current subject of this expectation.
Return
an Expect for the subject of this expectation.
Since
1.3.0
Samples
val exception = SQLException("Test exception", "42000", 1001)
expect(exception).sqlState { // subject within this expectation-group is of type String
toEqual("42000")
toContain("42")
} // subject here is back to type SQLException
fails {
expect(exception).sqlState {
toEqual("00000") // fails
toContain("42") // still evaluated even though `toEqual` already fails
}
}Creates an Expect for the result of calling getSQLState() on the subject of this expectation, so that further fluent calls are assertions about it.
Return
The newly created Expect for the extracted feature.
Since
1.3.0
Samples
val exception = SQLException("Test exception", "42000", 1001)
expect(exception).errorCode { // subject within this expectation-group is of type Int
toBeGreaterThan(1000)
toEqual(1001)
} // subject here is back to type SQLException
fails {
expect(exception).errorCode {
toEqual(9999) // fails
toBeGreaterThan(1000) // still evaluated even though `toEqual` already fails
}
}