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

Command Chain + Power Assert doesn't work

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.8.0
    • None
    • syntax
    • None

    Description

      Command Chaining cannot be used in conjunction with Power Asserts:

      class Driver {
          static EnterInto enter(text) {
              new EnterInto(text: text)
          }
      }
      
      class EnterInto {
          def text
          
          def into(field) {
              println "enter $text into $field"
              text
          }
      }
      
      import static Driver.*
      
      assert "1234" == enter("1234").into("field1") 
      def value = enter "5678" into "field2"
      assert "5678" == value
      //assert "9012" == enter "9012" into "field3"
      

      if the last assert is uncommented then a compilation error occurs.

      You can work around this problem by assigning the value to a temporary value and using the power asset on that value, but this means that you loose the breakdown from the power assert showing why the assert failed:

      assert "1234" == enter("2345").into("field1")
                    |  |             |
                    |  |             2345
                    |  EnterInto@882dfc
                    false
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            richard.allwood Richard Allwood
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: