| |
|
| java.lang.Object test.net.sourceforge.pmd.stat.StatisticalRuleTest
StatisticalRuleTest | public class StatisticalRuleTest (Code) | | This class tests the Statistical Rules in PMD.
The idea is, that we fill up 999 datapoints into
the Stat Rule, and then throw random parameters
at it.
The three parameters which are checked are:
sigma - # Sigmas over the mean.
topscore - Only the top 5 or so items.
minimum - Only things of score 10 or better
When more than one parameter is lumped together, then
we expect the one which would return the fewest to
determine what gets sent back.
So, we throw each collection of parameters, where each
one is a different order into the system. We check the
results off of what the smallest value should be.
If you are going to work with StatisticalRule any, please
bump the "NUM_TESTS" number up to something like 128. That
way you are more likely to identify problems. It is set low
now to make building and running tests easier (when we aren't
touching the file.)
Note also, that when verifying the Sigma, I wasn't quite able
to determine how many results it would return (it would vary
from -2 to 2 of what I expected.) That is what the delta
parameter on the verify method takes. If you can figure it
out exactly, (without stealing code from the StatRule) then
feel free to change it and tighten the deltas.
|
DELTA | final public static double DELTA(Code) | | |
MAX_MINIMUM | final public static double MAX_MINIMUM(Code) | | |
MAX_SIGMA | final public static double MAX_SIGMA(Code) | | |
MEAN | final public static double MEAN(Code) | | |
MIN_TOPSCORE | final public static int MIN_TOPSCORE(Code) | | |
NO_MINIMUM | final public static double NO_MINIMUM(Code) | | |
NO_SIGMA | final public static double NO_SIGMA(Code) | | |
NO_TOPSCORE | final public static int NO_TOPSCORE(Code) | | |
NUM_TESTS | final public static int NUM_TESTS(Code) | | |
SIGMA | final public static double SIGMA(Code) | | |
expectedMinimum | public int expectedMinimum(double minimum)(Code) | | This returns the expected number of reports.
If the Minimum comes in at 521.569 then we expect
522, 523, ... 999 will pass.
|
expectedSigma | public int expectedSigma(double sigma)(Code) | | This returns the expected number of results when
the Sigma rating is the smallest.
|
expectedTopScore | public int expectedTopScore(int target)(Code) | | This will return the expected number of results
with the given Top Score.
|
randomMinimum | public double randomMinimum()(Code) | | This generates a random minimum value for testing.
|
randomMinimum | public double randomMinimum(int minimum)(Code) | | This generates a random minimum value for which fewer
results would be returned.
|
randomSigma | public double randomSigma()(Code) | | This returns a Random value for Sigma which will
return some values.
|
randomSigma | public double randomSigma(int minimum)(Code) | | This returns a Random value for Sigma which value
is greater than the parameter.
|
randomTopScore | public int randomTopScore()(Code) | | This returns a random value for Top Score.
|
randomTopScore | public int randomTopScore(double target)(Code) | | This will return a random value for the Top Score
which will return more than the minimum provided.
|
setUp | public void setUp()(Code) | | |
suite | public static junit.framework.Test suite()(Code) | | |
testExpectedMinimum | public void testExpectedMinimum()(Code) | | |
testMetrics | public void testMetrics() throws Throwable(Code) | | This test verifies that the Stat rule creates a Metric,
with the proper values.
|
testSingleDatapoint | public void testSingleDatapoint()(Code) | | |
verifyResults | public void verifyResults(double sigma, double minimum, int topScore, int expected, int delta)(Code) | | Verifies what happens when you pass these parameters
into the thing. DELTA is the amount of error allowed.
Usually DELTA is only used for Sigma, as we really can't
calculate it exactly.
|
|
|
|