You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Dave Brondsema <da...@brondsema.net> on 2008/02/04 05:19:01 UTC

unit testing a plugin

Is there a recommended way to unit test methods in a SpamAssassin plugin?

I've written Mail::SpamAssassin::Plugin::Konfidi (and also an OpenPGP 
plugin) and wrote some unit tests for the main scoring method, but it 
isn't the cleanest.  You can see what I have at 
http://search.cpan.org/src/BRONDSEM/Mail-SpamAssassin-Plugin-Konfidi-1.0.1/t/unit.t 


It works, but I'm looking for any recommendations for a better way to do 
it.  One thing that I already know I should fix is to have a new mock 
perMsgStatus for each test instead of reusing it.  Improvements I would 
want are: not writing/reading into internal data structures of 
perMsgStatus (or are those fairly stable?) and redefining the 'dbg' 
method to use Test's diag.

Thanks,

-- 
Dave Brondsema : dave@brondsema.net
http://www.brondsema.net : personal
http://www.splike.com : programming
                <><