Enum comparison with String is not working with recursive assertion
See original GitHub issueSummary
Comparison of enum with string fails with recursive assertion and strictTypeChecking
as false. I would expect below code to be run successfully.
actual and expected objects and their fields were compared field by field recursively even if they were not of the same type
- as per error, actual and expected values are same (CAR in below example) and test case should pass.
Example
public class TestEnumWithString {
@Test
public void testEnumWithString() {
assertThat(Vehicle.CAR).usingRecursiveComparison().isEqualTo("CAR");
}
}
enum Vehicle {
CAR
}
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Enum comparison with String is not working with recursive ...
Comparison of enum with string fails with recursive assertion and strictTypeChecking as false. I would expect below code to be run successfully.
Read more >How to compare a string with a python enum? - Stack Overflow
Solved my problem. Though I could not use Signal(brain_detected_colour) is Signal.red (mentioned at the end of the answer, for when an enum is ......
Read more >Java static code analysis: Enum values should be compared ...
Enum values should be compared with "==" · provides the same expected comparison (content) as equals · is more null-safe than equals() ·...
Read more >AssertJ - fluent assertions java library - GitHub Pages
Example for String assertions: ... Fix Recursive comparison that did not compare enums as they don't have fields, now it compares enums with...
Read more >Working with enums in Go | Emir Ribic
IllegalArgumentException: No enum constant . With Go, it's different. Most often you create a custom type ( LeaveType ) and define constants 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 FreeTop 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
Top GitHub Comments
@joel-costigliola - I’m using latest version 3.22.0.
Closing this issue as we can register specific comparison/equals for types or fields which I think cover the use case. Happy to reopen if that turns our not to be true.