Hackerpilot/Dscanner — pull request #173 by workhorsy (2014-05-17 19:38:05+00:00)
Title: Unit tests for analyzers

Are you interested in adding unit tests to the analyzers? If so I have been toying around with an idea for how to test them. Basically you have a token string with your code in it. Then you put a comment with the expected [warn] message in it. This way the assert function can check the line numbers automatically.

```
unittest
{
assertAnalyzerWarnings(q{
class Dog {} // ok
class cat {} // [warn]: Class name 'cat' does not match style guidelines
}c, analysis.run.AnalyzerCheck.style_check);

stderr.writeln("Unittest for StyleChecker passed.");
}
```

I had to make a few changes to the way tests are run. And some of the existing tests were not working.

This seems like a decent starting point. Let me know what you think.