Kotlin: Support `assertThat(foo) { isNotNull() isNotEqualTo(bar) ... }`
See original GitHub issueIt’s already possible to write nearly that by using apply:
assertThat(foo).apply {
isNotNull()
isNotEqualTo(bar)
}
Might it be worth a shortcut? Anecdotes welcome.
Issue Analytics
- State:
- Created 4 years ago
- Comments:29 (22 by maintainers)
Top Results From Across the Web
AssertJ - fluent assertions java library - GitHub Pages
entry point for all assertThat methods and utility methods (e.g. entry) import static org.assertj.core.api.Assertions.
Read more >Subject: Remove named(), actual(), and type parameters - Truth
AssertJ also defines most assertion methods to return the Subject , enabling chains like assertThat(x).isNotNull().isNotEqualTo(other).contains(x) , which we've ...
Read more >Why doesn't this assert work - assertThat(foo, is(not(null)))
Empirically, I've found that this works instead: assertThat(foo, is(not(nullValue())));.
Read more >Diff - platform/frameworks/support - Google Git
setOnContentRefreshListener(listener) + .build(); + + assertThat(template) + .isNotEqualTo( + new PlaceListMapTemplate.Builder() + .setTitle("Title") + .
Read more >Spring Boot Reference Documentation
Spring Boot Applications Deployment: Cloud Deployment | OS Service. Build tool plugins: Maven | Gradle. Appendix: Application Properties | Configuration ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thinking a little more about
foo.assertThat. I think, if we were to do it, it should not take a subject-receiver lambda, but instead a subject-parameter lambda so that it reads better as an English phrase:Thinking further, I now think the right idiom is:
That is very close to what I suggested above about using “it”, and uses only standard Kotlin, requiring no Truth API changes at all.
There is a small risk of someone dangling an assertion modifier off the end of the
let(e.g.,foo.let { ... }.inOrder()), but that could be mitigated with a check that flags any method call on aSubjectwhose receiver is a scope function call.