Groovy
  1. Groovy
  2. GROOVY-4520

Groovy power assert is confusing if no types are displayed

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7.5
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
      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.

        Issue Links

          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:

                Development