Uploaded image for project: 'TestBox'
  1. TESTBOX-58

toThrow() cannot match empty message & cannot match detail

    Details

    • Type: Bug
    • Status: Closed (View workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0
    • Fix Version/s: 1.1.0
    • Component/s: Assertions
    • Labels:
      None

      Description

      ColdSpring throws coldspring.NoSuchBeanDefinition when you request a non-existent bean, e.g., Wibble, but it uses an empty message and a detail of "Bean definition for bean named: Wibble could not be found."

      Assertion.throws() will not match any empty message: reFindNoCase( "", "" ) returns zero, as does reFindNoCase( "^$", "" ) so it seems that a special case is needed for e.message.

      In addition, you can't match on the detail of an exception at all which means you can't differentiate between two similar exceptions.

      I'm not quite sure what the best solution is here. I'd be tempted to change both calls of reFindNoCase( arguments.regex, e.message ) to ( reFindNoCase( arguments.regex, e.message ) || reFindNoCase( arguments.regex, e.detail ) ). That would solve the immediate problem insofar as you could then match on detail OR message.

      Longer term, adding support for matching detail separately and special-casing for message / detail being empty strings would probably be a better solution.

      Thoughts?

      FWIW, I made the simple change locally of testing regex against message or detail and that's working nicely for me.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                lmajano Luis Majano
                Reporter:
                seancorfield Sean Corfield
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: