001: /*
002: * @(#)GroboReportTaskUTest.java
003: *
004: * Copyright (C) 2004 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.sourceforge.groboutils.codecoverage.v2.ant;
028:
029: import java.io.File;
030: import java.io.IOException;
031: import java.util.Properties;
032:
033: import junit.framework.Test;
034: import junit.framework.TestSuite;
035: import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
036:
037: /**
038: * Tests the GroboReportTask class.
039: *
040: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
041: * @version $Date: 2004/04/15 05:48:27 $
042: * @since March 13, 2004
043: */
044: public class GroboReportTaskUTest extends AntTestA {
045: //-------------------------------------------------------------------------
046: // Standard JUnit Class-specific declarations
047:
048: private static final Class THIS_CLASS = GroboReportTaskUTest.class;
049: private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
050:
051: public GroboReportTaskUTest(String name) {
052: super (name);
053: }
054:
055: //-------------------------------------------------------------------------
056: // Tests
057:
058: //...........................
059: // Tests that pass
060:
061: public void testReport1() {
062: executeTarget("report-1");
063: }
064:
065: public void testReport2() {
066: executeTarget("report-2");
067: }
068:
069: public void testReport3() {
070: try {
071: executeTarget("report-3");
072: } finally {
073: System.out.println(getFullLog());
074: }
075: }
076:
077: public void testReport4() {
078: executeTarget("report-4");
079: }
080:
081: //...........................
082: // Tests that fail
083:
084: public void testFReport1() {
085: expectBuildExceptionContaining("f-report-1",
086: "Did not fail for no destdir attribute.",
087: "Must set the 'destdir' attribute.");
088: }
089:
090: //-------------------------------------------------------------------------
091: // Helpers
092:
093: protected void assertEquals(String text, Properties expected,
094: Properties actual) {
095: PropertyCheckUtil.assertEquals(text, expected, actual);
096: }
097:
098: protected Properties loadGroboProperties() throws IOException {
099: return loadProperties((new File(getCoverageDir(), "classes"
100: + File.separator + "grobocoverage.properties"))
101: .getAbsolutePath());
102: }
103:
104: protected Properties loadProperties(String file) throws IOException {
105: return PropertyCheckUtil.loadProperties(file);
106: }
107:
108: protected File getCoverageDir() {
109: return new File(getProjectDir(), "instrument" + File.separator
110: + "coverage");
111: }
112:
113: //-------------------------------------------------------------------------
114: // Standard JUnit declarations
115:
116: public static Test suite() {
117: TestSuite suite = new TestSuite(THIS_CLASS);
118:
119: return suite;
120: }
121:
122: public static void main(String[] args) {
123: String[] name = { THIS_CLASS.getName() };
124:
125: // junit.textui.TestRunner.main( name );
126: // junit.swingui.TestRunner.main( name );
127:
128: junit.textui.TestRunner.main(name);
129: }
130:
131: /**
132: *
133: * @exception Exception thrown under any exceptional condition.
134: */
135: protected void setUp() throws Exception {
136: super .setUp();
137:
138: // set ourself up
139: configureProject("report.xml");
140: }
141:
142: /**
143: *
144: * @exception Exception thrown under any exceptional condition.
145: */
146: protected void tearDown() throws Exception {
147: // tear ourself down
148: executeTarget("test-teardown");
149:
150: super.tearDown();
151: }
152: }
|