Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put test assertion errors on multiple lines #2755

Closed
barbeque-squared opened this issue Jun 16, 2023 · 1 comment · Fixed by #2757
Closed

Put test assertion errors on multiple lines #2755

barbeque-squared opened this issue Jun 16, 2023 · 1 comment · Fixed by #2757
Assignees
Labels
Priority 4: Would Lowest priority. Would-be-nice to include issues when time allows it. Status: Resolved Use to signal that work on this issue is done. Type: Enhancement Use to signal an issue enhances an already existing feature of the project.
Milestone

Comments

@barbeque-squared
Copy link
Contributor

Enhancement Description

Put test failure messages (at least org.axonframework.test.AxonAssertionError, but there's probably more: search the codebase for "but got") on separate lines. This doesn't really matter for something simple like an integer, but when it starts printing events with half a dozen or so fields, this would make it much easier to debug.

This happens at least when something is failing in AggregateTestFixture's expectEvents method. Maybe some of the places the above search query returns don't need this, and maybe there's other places, but I'm fine with incremental improvements.

Current/Wanted behaviour examples are adapted from a real test I was working on, just the field names and contents have been scrubbed a bit.

Current Behaviour

org.axonframework.test.AxonAssertionError: One of the messages contained a different payload than expected

The message of type [MyAwesomeEvent] was not as expected.
Expected <MyAwesomeEvent(someIdentifier=awesomeId, anotherId=example, name=facts.doc, description=Axon is really awesome, version=1.0, hierarchy1=null, hierarchy2=null, hierarchy3=null, uploadedBy=uploadedBy, uploadedAt=2023-06-16T08:10:12.713542187, userType=USER, year=2023)> but got <MyAwesomeEvent(someIdentifier=awesomeId, anotherId=example, name=facts.doc, description=null, version=null, hierarchy1=null, hierarchy2=null, hierarchy3=null, uploadedBy=, uploadedAt=2023-06-16T08:10:12.713542187, userType=USER, year=2023)>

Wanted Behaviour

org.axonframework.test.AxonAssertionError: One of the messages contained a different payload than expected

The message of type [MyAwesomeEvent] was not as expected.
Expected <MyAwesomeEvent(someIdentifier=awesomeId, anotherId=example, name=facts.doc, description=Axon is really awesome, version=1.0, hierarchy1=null, hierarchy2=null, hierarchy3=null, uploadedBy=uploadedBy, uploadedAt=2023-06-16T08:10:12.713542187, userType=USER, year=2023)>
 but got <MyAwesomeEvent(someIdentifier=awesomeId, anotherId=example, name=facts.doc, description=null, version=null, hierarchy1=null, hierarchy2=null, hierarchy3=null, uploadedBy=, uploadedAt=2023-06-16T08:10:12.713542187, userType=USER, year=2023)>

Notice how it's immediately and trivially clear that description is the first field it's failing on.

Possible Workarounds

Copy pasting the test output into an editor and adding a newline manually (this is what I currently do)

@barbeque-squared barbeque-squared added the Type: Enhancement Use to signal an issue enhances an already existing feature of the project. label Jun 16, 2023
@smcvb smcvb self-assigned this Jun 16, 2023
@smcvb smcvb added Priority 4: Would Lowest priority. Would-be-nice to include issues when time allows it. Status: In Progress Use to signal this issue is actively worked on. labels Jun 16, 2023
@smcvb smcvb added this to the Release 4.8.0 milestone Jun 16, 2023
@smcvb
Copy link
Member

smcvb commented Jun 16, 2023

Simple adjustment to make, I like it. As I'm finalizing 4.8.0, I think it makes sense to fit this in.

smcvb added a commit that referenced this issue Jun 16, 2023
Ensure all assertion messages thrown by Axon Framework in faulty test
scenarios are aligned. As part of this, align the actual and expected
values on separate lines for clarity.

#2755
smcvb added a commit that referenced this issue Jun 16, 2023
Update copyright notices

#2755
smcvb added a commit that referenced this issue Jun 19, 2023
Drop use of format to satisfy \n usage for SonarCloud

#2755
smcvb added a commit that referenced this issue Jun 19, 2023
…ne-assertion-messages

[#2755] Align assertion messages
@smcvb smcvb added Status: Resolved Use to signal that work on this issue is done. and removed Status: In Progress Use to signal this issue is actively worked on. labels Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority 4: Would Lowest priority. Would-be-nice to include issues when time allows it. Status: Resolved Use to signal that work on this issue is done. Type: Enhancement Use to signal an issue enhances an already existing feature of the project.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants