comparison gwt-client/src/test/java/test/AbstractBerechnungsartenTester.java @ 9570:531a60b7af95

failed tests will be saved to disk
author gernotbelger
date Mon, 05 Nov 2018 17:15:30 +0100
parents 86e522bc7f36
children
comparison
equal deleted inserted replaced
9569:9f83ebf67c92 9570:531a60b7af95
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the 7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8 * documentation coming with Dive4Elements River for details. 8 * documentation coming with Dive4Elements River for details.
9 */ 9 */
10 package test; 10 package test;
11 11
12 import java.io.File;
13 import java.io.IOException;
14 import java.util.Iterator;
15
16 import org.apache.commons.io.FileUtils;
17 import org.junit.AfterClass;
18 import org.junit.BeforeClass;
19
12 /** 20 /**
13 * @author Domenico Nardi Tironi 21 * @author Domenico Nardi Tironi
14 * 22 *
15 */ 23 */
16 public abstract class AbstractBerechnungsartenTester { 24 public abstract class AbstractBerechnungsartenTester {
17 25
18 // for common Settings 26 // for common Settings
19 // 27 //
28 protected static File testFolder;
29
20 protected enum FileExportBehaviour { 30 protected enum FileExportBehaviour {
21 do_not_override, export_all, export_none; 31 do_not_override, export_all, export_none;
22 // do_not_override: file export is set individually (not overridden) 32 // do_not_override: file export is set individually (not overridden)
23 // true: all test files created by running jUnit-Tests will be written to disk 33 // true: all test files created by running jUnit-Tests will be written to disk
24 // false: no file will be exported 34 // false: no file will be exported
26 36
27 public static enum River { 37 public static enum River {
28 Beispielfluss, Rhein, Elbe 38 Beispielfluss, Rhein, Elbe
29 }; 39 };
30 40
41 @BeforeClass
42 public static final void createTempFolder() {
43 // windows: C:\Users\USER_NAME\AppData\Local\Temp
44 if (testFolder == null) {
45 testFolder = new File(FileUtils.getTempDirectory(), "FlysTestFolder");
46 if (!testFolder.isDirectory())
47 testFolder.mkdir();
48 }
49 }
50
51 @AfterClass
52 public static void deleteTempFolder() {
53
54 testFolder = new File(FileUtils.getTempDirectory(), "FlysTestFolder");
55 if (testFolder.isDirectory() && testFolder.exists()) {
56
57 try {
58 final Iterator<File> test = FileUtils.iterateFiles(testFolder, null, true);
59 if (!test.hasNext()) {
60 FileUtils.deleteDirectory(testFolder);
61
62 testFolder = null;
63 }
64 }
65 catch (final IOException e) {
66 e.printStackTrace();
67 }
68 }
69 }
31 } 70 }

http://dive4elements.wald.intevation.org