groovy
  1. groovy
  2. GROOVY-4520

Groovy power assert is confusing if no types are displayed

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7.5
    • Fix Version/s: 2.x
    • Component/s: groovy-runtime
    • Labels:
      None
    • Number of attachments :
      0

      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.

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Evgeny Goldin
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: