KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > metrics > CyclomaticComplexityCheckTest


1 package com.puppycrawl.tools.checkstyle.checks.metrics;
2
3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5
6 public class CyclomaticComplexityCheckTest
7     extends BaseCheckTestCase
8 {
9     public void test() throws Exception JavaDoc
10     {
11         final DefaultConfiguration checkConfig =
12             createCheckConfig(CyclomaticComplexityCheck.class);
13
14         checkConfig.addAttribute("max", "0");
15
16         final String JavaDoc[] expected = {
17             "4:5: Cyclomatic Complexity is 2 (max allowed is 0).",
18             "7:17: Cyclomatic Complexity is 2 (max allowed is 0).",
19             "17:5: Cyclomatic Complexity is 6 (max allowed is 0).",
20             "27:5: Cyclomatic Complexity is 3 (max allowed is 0).",
21             "34:5: Cyclomatic Complexity is 5 (max allowed is 0).",
22             "48:5: Cyclomatic Complexity is 3 (max allowed is 0).",
23             "58:5: Cyclomatic Complexity is 3 (max allowed is 0).",
24             "67:5: Cyclomatic Complexity is 3 (max allowed is 0).",
25             "76:5: Cyclomatic Complexity is 1 (max allowed is 0).",
26             "79:13: Cyclomatic Complexity is 2 (max allowed is 0).",
27         };
28
29         verify(checkConfig, getPath("ComplexityCheckTestInput.java"), expected);
30     }
31 }
32
Popular Tags