KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > firstpartners > nounit > snippet > test > TestSnippets


1 package net.firstpartners.nounit.snippet.test;
2
3 /**
4  * Title: NoUnit - Identify Classes that are not being unit Tested
5  *
6  * Copyright (C) 2001 Paul Browne , FirstPartners.net
7  *
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * @author Paul Browne
24  * @version 0.7
25  */

26 import java.util.HashMap JavaDoc;
27 import java.util.Iterator JavaDoc;
28
29 import junit.framework.Test;
30 import junit.framework.TestCase;
31 import junit.framework.TestSuite;
32 import net.firstpartners.nounit.snippet.ISnippet;
33 import net.firstpartners.nounit.snippet.SnippetClass;
34 import net.firstpartners.nounit.snippet.SnippetMethod;
35 import net.firstpartners.nounit.snippet.Snippets;
36
37 /**
38  * Test the Class Snippet Factory<BR>
39
40  */

41 public class TestSnippets extends TestCase {
42
43   /**
44    * Constructor as required by Junit
45    * @param name to be displayed on testrunner
46    */

47     public TestSnippets(String JavaDoc name) {
48     super(name);
49   }
50
51   /**
52    * Code run before each test
53    */

54   public void setUp(){
55
56   }
57
58   /**
59    * Code run after each test
60    */

61   protected void tearDown()
62   {
63
64   }
65
66   /**
67   * Enable Junit to run this Class individually
68   * @param args
69   */

70   public static void main(String JavaDoc[] args) {
71       junit.textui.TestRunner.run (suite());
72   }
73
74   /**
75    * Enable Junit to run this class as part of AllTests.java
76    * @return TestSuite
77    */

78   public static Test suite() {
79       return new TestSuite(TestSnippets.class);
80   }
81   
82     public void testSnippets() throws Exception JavaDoc {
83       
84         SnippetClass testSClass = new SnippetClass("","","",new Snippets());
85         SnippetMethod testSMethod = new SnippetMethod("","",new HashMap JavaDoc(),null);
86         
87         Snippets mySet = new Snippets();
88         mySet.add(testSClass);
89         mySet.add(testSMethod);
90         
91         //Now Test Iterator
92
Iterator JavaDoc testIterator = mySet.getIterator();
93         while (testIterator.hasNext()) {
94             assertTrue(testIterator.next() instanceof ISnippet);
95         }
96         
97            
98   }
99   
100
101 }
Popular Tags