Package: TestResourcesResultTestCase

TestResourcesResultTestCase

nameinstructionbranchcomplexitylinemethod
TestResourcesResultTestCase()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
TestResourcesResultTestCase(File)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
TestResourcesResultTestCase(File, String, File)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
TestResourcesResultTestCase(File, String, String)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
createResultFile(String)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getResultDirectoryPath()
M: 85 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
getResultFile(String)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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: public abstract class TestResourcesResultTestCase<R> extends ResultTestCase<R>
27: {
28:         protected final File testSuiteRoot;
29:         protected final String suiteName;
30:
31:         public TestResourcesResultTestCase()
32:         {
33:                 super();
34:                 testSuiteRoot = null;
35:                 suiteName = null;
36:         }
37:
38:         public TestResourcesResultTestCase(File file)
39:         {
40:                 super(file);
41:                 testSuiteRoot = null;
42:                 suiteName = null;
43:         }
44:
45:         public TestResourcesResultTestCase(File rootSource, String name,
46:                         String content)
47:         {
48:                 super(rootSource, name, content);
49:                 testSuiteRoot = null;
50:                 suiteName = null;
51:         }
52:
53:         public TestResourcesResultTestCase(File file, String suiteName,
54:                         File testSuiteRoot)
55:         {
56:                 super(file);
57:                 this.testSuiteRoot = testSuiteRoot;
58:                 this.suiteName = suiteName;
59:         }
60:
61:         @Override
62:         protected File createResultFile(String filename)
63:         {
64:                 new File(getResultDirectoryPath()).mkdirs();
65:                 return getResultFile(filename);
66:         }
67:
68:         @Override
69:         protected File getResultFile(String filename)
70:         {
71:                 return new File(new File(getResultDirectoryPath()), filename);
72:         }
73:
74:         private String getResultDirectoryPath()
75:         {
76:                 // first try choice 1
77:•                if (testSuiteRoot != null)
78:                 {
79:                         String base = file.getParentFile().getAbsolutePath();
80:                         String suiteBase = testSuiteRoot.getAbsolutePath();
81:•                        if (base.startsWith(suiteBase)
82:•                                        && base.length() != suiteBase.length())
83:                         {
84:                                 String tmp = ("src/test/resources/" + suiteName + "/" + base.substring(suiteBase.length() + 1)).replace('\\', '/').replace('/', File.separatorChar).replaceAll(" ", "");
85:                                 return tmp;
86:                         }
87:                 }
88:
89:                 String tmp = file.getParentFile().getPath();
90:                 tmp = tmp.replace('\\', '/');
91:•                if (tmp.startsWith("/") || tmp.contains(":"))
92:                 {
93:                         tmp = tmp.substring(tmp.indexOf('/') + 1);
94:                 }
95:                 return tmp.replace('/', File.separatorChar).replaceAll(" ", "");
96:         }
97:
98: }