Optionally generate AssertJ assertions for generated Immutable types
See original GitHub issueIt would be really cool, if at the same time as generating the immutable classes, custom assertions could be generated. AssertJ has an implementation which could be run from the annotation processor. This would mean clean tests when using in the same project or downstream.
Not sure how it would work. Maybe the processor could detect the presence of an assertion generator (AssertJ/Google Truth etc) and then generate.
There could be a an assertion
flag on @Style?
or a new annotation?
Many ways to do it.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
AssertJ Assertions Generator
Use the Assertion Generator to create assertions specific to your own classes, either through a simple command line tool, a maven plugin or...
Read more >Java static code analysis: Chained AssertJ assertions should ...
Chained AssertJ assertions should be simplified to the corresponding dedicated assertion ... AssertJ contains many assertions methods specific to common types.
Read more >Write BDD Unit Tests with BDDMockito and AssertJ
Vanilla AssertJ uses the method Assertions.assertThat(actual) (abbreviated as assertThat(actual) to create the assertion type using the static ...
Read more >Generated assertions do not preserve generic types · Issue #92
For example, if I have: public final Optional foo;, the generated ... Nava2 added a commit to Nava2/assertj-assertions-generator that ...
Read more >Testing - Spring
For example, a mock request is immutable once created, ... uses the SpringExtension for JUnit Jupiter and AssertJ to assert the types of ......
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
Can you show some example of assertions you want to be executed ? Why do they have to be run from annotation processor ?
Thanks for the pointer to the evaluator. It should indeed be possible to enhance that for assertJ like expressive messages.
From what I remember from the assertj inner workings it’s more comparable to the let’s say builder code generated by immutables. There is no “runtime system” or “evaluator” that can be “programmed”. It’s static code that allows writing fluent assertions and the error reporting is baked in.