Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-19566

Refactoring of regular expressions and unit test best practice

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.9.5
    • Fix Version/s: None
    • Component/s: Unit tests
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      Regular expressions are very powerful, but most of them in Moodle are untested. Ideally we should unit-test every regular expression with a wide range of inputs.

      This is difficult for one main reason: often the regular expressions are not accessible to unit tests, they are deeply embedded in the logic and have strong coupling.

      One solution is to extract all static regular expressions into constants, and dynamic expressions into functions. Unit tests can then be written for them easily.

        Attachments

          Activity

            People

            • Assignee:
              skodak Petr Skoda
              Reporter:
              nicolasconnault Nicolas Connault
              Participants:
              Component watchers:
              Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: