I'm using google truth for test assertions. Is my ...
# random
c
I'm using google truth for test assertions. Is my googling failing me, or is there no way to "fail" a test?
Copy code
when (val foo = something) {
    is One -> fail() <===== I just want to fail if foo is of type One
    is Two -> assertThat(bar).isNotEmpty()
    null -> TODO()
}
t
not that I use truth, but does not https://github.com/google/truth/issues/351 work? otherwise just go hacking mode, assert true is false with a custom message 🤷
c
nope. no dice. I guess assert true is false it is... lmao
t
there is
Truth.assert_().fail()
, but I like hacks 😄
Copy code
import com.google.common.truth.Truth

Truth.assert_().withMessage("something something").fail()
though it prints the message twice to me
🤯 2
k
You could always just use JUnit's fail().
👍 2
👍🏾 1