Package: BaseTestCase$ContentModed

BaseTestCase$ContentModed

nameinstructionbranchcomplexitylinemethod
static {...}
M: 0 C: 34
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%~
3: * Test Framework for Overture
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.test.framework;
23:
24: import java.io.File;
25:
26: import junit.framework.TestCase;
27:
28: public abstract class BaseTestCase extends TestCase
29: {
30:         protected File file;
31:         protected String name;
32:         protected String content;
33:
34:         protected enum ContentModed
35:         {
36:                 File, String, None
37:         };
38:
39:         protected final ContentModed mode;
40:
41:         public BaseTestCase()
42:         {
43:                 super("skip");
44:                 mode = ContentModed.None;
45:         }
46:
47:         public BaseTestCase(File file)
48:         {
49:                 super("test");
50:                 this.file = file;
51:                 this.content = file.getName();
52:                 mode = ContentModed.File;
53:         }
54:
55:         public BaseTestCase(File rootSource, String name, String content)
56:         {
57:                 super("test");
58:                 this.content = content;
59:                 this.name = name;
60:                 this.file = rootSource;
61:                 mode = ContentModed.String;
62:         }
63:
64:         @Override
65:         public String getName()
66:         {
67:                 if (name != null)
68:                 {
69:                         return name;
70:                 } else if (file != null)
71:                 {
72:                         String newName = null;
73:                         String name = file.getName();
74:                         if (name.contains("."))
75:                         {
76:                                 newName = name.substring(0, name.indexOf("."));
77:                         }
78:                         if (newName == null)
79:                         {
80:                                 newName = file.getName();
81:                         }
82:
83:                         return newName + " <" + file.getParentFile().getName() + ">";
84:
85:                 }
86:                 return "Generic Base Test";
87:         }
88:
89:         public abstract void test() throws Exception;
90:
91:         public static String pad(String text, int length)
92:         {
93:                 if (text == null)
94:                 {
95:                         text = "null";
96:                 }
97:                 while (text.length() < length)
98:                 {
99:                         text += " ";
100:                 }
101:                 return text;
102:         }
103:
104:         public void skip()
105:         {
106:         };
107: }