Do you test your regular expressions?

Last updated by Igor Goldobin about 2 months ago.See history

Everyone writes unit tests for their code, because it helps developer to make changes in future without breaking existing functionalities. The same goes for regular expressions. A good regular expression will have a set of test cases to make sure any future changes does not invalidate existing requirements.

You should not fix a regular expression until we have added a good and a bad test case.

If your application is driven by regular expressions, you need a good test harness. Here is an example of a test harness we use in CodeAuditor.

Figure: Test Harness for regular expressions in CodeAuditor

We open source. Powered by GitHub