Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4520

Groovy power assert is confusing if no types are displayed

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.5
    • None
    • groovy-runtime
    • None

    Description

      In the following code

      def j = "5"
      assert 5 == j
      
      Assertion failed: 
      
      assert 5 == j
               |  |
               |  5
               false
      

      it is confusing to understand why assert fails if no types are displayed. Variables compared may be different but their toString() representations used by assert error message may be identical.

      Another example I had was:

      assert pomSize == project.properties.pomSize
             |       |  |       |          |
             2607    |  |       |          2607
                     |  |       [pomSize:2607, gmavenVersion:1.3]
                     |  MavenProject: com.goldin:groovymag.listing-1:12.2010 @ E:\Projects\GroovyMag\December-2010\Listing-1\pom.xml
                     false
      

      Here I had a number 2607 on the left, but a String "2607" on the right.

      I suggest to add types of variables compared in assert.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              genie Evgeny Goldin
              Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: