Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code coverage tools for regexes? [closed]

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.)

like image 830
Steven Ourada Avatar asked Sep 05 '10 04:09

Steven Ourada


2 Answers

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.

like image 82
Jimmy Avatar answered Oct 21 '22 06:10

Jimmy


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.

like image 21
hydrogen Avatar answered Oct 21 '22 07:10

hydrogen