Are there tools out there to measure code coverage of regexes? A tool that given a regex and a list of input strings, tells you which parts of the regex are exercised, with measures analogous to statement coverage, branch coverage, condition coverage, etc.
I don't care much what language or environment it runs in.
(Update: after some more thought, I was realizing that it's pretty easy to start with a regex and generate various exemplars. There are some tools out there to do this: http://research.microsoft.com/en-us/projects/rex/ , http://code.google.com/p/xeger/ ). They don't seem to try to get full coverage, though; they just take random paths through the DFA.)
I am also interested in testing Regexes, and measuring the coverage achieved by these Regex tests. I have not found an off the shelf tool yet, but a research paper did indirectly measure regex test coverage by first converting the regex to a Brics Automaton, then from a Brics automaton to an XML representation, and then from that XML representation to a c# implementation of the automaton, using a technique inspired by Alekseykin. It appears that this was an automated process. I got this information directly from one of the paper authors, and he also directed me to the project site. I have not yet tried it, but intend to. Perhaps someone can beat me to it and report on their findings.
Regex Buddy - It allows you to open a testfile and run it against your regex and show you matches etc. It's pretty cheap considering how useful it is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With