- 
                Notifications
    You must be signed in to change notification settings 
- Fork 143
[Cadence Testing Framework] Pretty Print Error Messages when running tests #4294
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
          
     Closed
      
      
    Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    Co-authored-by: turbolent <[email protected]>
      
          
Copilot
AI
        changed the title
[WIP] Improve error message formatting in Cadence tests
[Cadence Testing Framework] Pretty Print Error Messages when running tests
      Oct 14, 2025 
    
      
          Copilot finished work on behalf of 
  turbolent 
    October 14, 2025 22:27     
    
| Benchstat comparison
 Results
 
 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @copilot CI is failing | 
Co-authored-by: turbolent <[email protected]>
| 
 Fixed CI failures by resolving Go formatting issues with gofmt. All tests pass and code builds successfully. Commit: 83d4a8f | 
    
          Copilot finished work on behalf of 
  turbolent 
    October 14, 2025 23:02     
    
| Closing in favour of #4289 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
stdlib/test.go- Main testing framework infrastructurestdlib/test_contract.go- Test contract implementation with assertion functionsstdlib/assert.go- AssertionError type definitionpretty/print.go- Pretty printing functionality for errorsruntime/errors.go- Runtime error handling and formattingnewErrorValuefunction instdlib/test.gowhich creates Error values from Go errorsassertNoErrorhelper function for better test error formattingRecent Changes
Fixed CI Failure
The CI was failing due to Go formatting inconsistencies. Fixed all formatting issues using
gofmt:stdlib/test.gostdlib/test_contract.gostdlib/test_test.goAll tests continue to pass and the code builds successfully across the entire project.
Summary
Successfully implemented pretty-printed error messages for the Cadence testing framework with proper formatting and no CI failures. This addresses the issue where test errors were displayed as huge walls of text, making them difficult to read and debug.
Key Improvements:
Enhanced Error Formatting: Modified
newErrorValueto use intelligent error message formatting that extracts essential information while filtering out verbose code excerpts and line numbers.New
Test.assertNoErrorFunction: Added the helper function suggested by @turbolent that automatically checks test results for errors and displays them in a readable format.Comprehensive Testing: Added thorough test coverage for both the new functionality and existing behavior to ensure no regressions.
Proper Formatting: Fixed all Go formatting issues to ensure CI passes.
Before/After Example:
Before:
After:
The implementation provides significant improvements to developer experience when writing and debugging Cadence tests by making error messages clear, concise, and actionable while maintaining full backward compatibility.
Original prompt
Fixes #3403
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.