| Line | Hits | Note | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * $Id: FileSummaryTest.java 1481 2009-05-23 05:54:44Z amandel $ | ||
| 3 | * | ||
| 4 | * Copyright 2006, The jCoderZ.org Project. All rights reserved. | ||
| 5 | * | ||
| 6 | * Redistribution and use in source and binary forms, with or without | ||
| 7 | * modification, are permitted provided that the following conditions are | ||
| 8 | * met: | ||
| 9 | * | ||
| 10 | * * Redistributions of source code must retain the above copyright | ||
| 11 | * notice, this list of conditions and the following disclaimer. | ||
| 12 | * * Redistributions in binary form must reproduce the above | ||
| 13 | * copyright notice, this list of conditions and the following | ||
| 14 | * disclaimer in the documentation and/or other materials | ||
| 15 | * provided with the distribution. | ||
| 16 | * * Neither the name of the jCoderZ.org Project nor the names of | ||
| 17 | * its contributors may be used to endorse or promote products | ||
| 18 | * derived from this software without specific prior written | ||
| 19 | * permission. | ||
| 20 | * | ||
| 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND | ||
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS | ||
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
| 28 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
| 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
| 30 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
| 31 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 32 | */ | ||
| 33 | package org.jcoderz.phoenix.report; | ||
| 34 | |||
| 35 | import junit.framework.TestCase; | ||
| 36 | |||
| 37 | /** | ||
| 38 | * Test the FileSummary class. | ||
| 39 | * @author Andreas Mandel | ||
| 40 | */ | ||
| 41 | 100 | public class FileSummaryTest | |
| 42 | extends TestCase | ||
| 43 | { | ||
| 44 | /** Test the {@link FileSummary#getNumberOfFindings()} method. */ | ||
| 45 | public void testGetNumberOfFindings () | ||
| 46 | { | ||
| 47 | 100 | final FileSummary testSummary = new FileSummary(); | |
| 48 | |||
| 49 | 100 | assertEquals("No violation at all.", 0, | |
| 50 | testSummary.getNumberOfFindings()); | ||
| 51 | 100 | testSummary.addViolation(Severity.FILTERED); | |
| 52 | 100 | assertEquals("Filtered should not be count.", 0, | |
| 53 | testSummary.getNumberOfFindings()); | ||
| 54 | 100 | testSummary.addViolation(Severity.OK); | |
| 55 | 100 | assertEquals("OK should not be count.", 0, | |
| 56 | testSummary.getNumberOfFindings()); | ||
| 57 | 100 | testSummary.addViolation(Severity.COVERAGE); | |
| 58 | 100 | assertEquals("COVERAGE is not expected to be count.", 0, | |
| 59 | testSummary.getNumberOfFindings()); | ||
| 60 | 100 | testSummary.addViolation(Severity.INFO); | |
| 61 | 100 | assertEquals("INFO is expected to be count.", 1, | |
| 62 | testSummary.getNumberOfFindings()); | ||
| 63 | 100 | testSummary.addViolation(Severity.CODE_STYLE); | |
| 64 | 100 | (1) | assertEquals("CODE_STYLE is expected to be count.", 2, |
| 65 | testSummary.getNumberOfFindings()); | ||
| 66 | 100 | testSummary.addViolation(Severity.CPD); | |
| 67 | 100 | (2) | assertEquals("CPD is expected to be count.", 3, |
| 68 | testSummary.getNumberOfFindings()); | ||
| 69 | 100 | testSummary.addViolation(Severity.DESIGN); | |
| 70 | 100 | (3) | assertEquals("DESIGN is expected to be count.", 4, |
| 71 | testSummary.getNumberOfFindings()); | ||
| 72 | 100 | testSummary.addViolation(Severity.ERROR); | |
| 73 | 100 | (4) | assertEquals("ERROR is expected to be count.", 5, |
| 74 | testSummary.getNumberOfFindings()); | ||
| 75 | 100 | testSummary.addViolation(Severity.WARNING); | |
| 76 | 100 | (5) | assertEquals("WARNING is expected to be count.", 6, |
| 77 | testSummary.getNumberOfFindings()); | ||
| 78 | |||
| 79 | 100 | } | |
| 80 | } |
|
|
(1) | 64 | : | 61 | '2' is a magic number. |
|
|
(2) | 67 | : | 54 | '3' is a magic number. |
|
|
(3) | 70 | : | 57 | '4' is a magic number. |
|
|
(4) | 73 | : | 56 | '5' is a magic number. |
|
|
(5) | 76 | : | 58 | '6' is a magic number. |