Ver código fonte

Some kind of crazy uber hacks to make UI tests work again

tags/0.6.3m1rc1
Chris Smith 15 anos atrás
pai
commit
bf158d9ba6

+ 0
- 4
test/com/dmdirc/addons/ui_swing/MainFrameTest.java Ver arquivo

@@ -134,8 +134,4 @@ public class MainFrameTest implements UITestIface {
134 134
         window.menuItemWithPath("Server", "Server settings").requireDisabled();
135 135
     }
136 136
 
137
-    public static junit.framework.Test suite() {
138
-        return new junit.framework.JUnit4TestAdapter(MainFrameTest.class);
139
-    }
140
-
141 137
 }

+ 14
- 0
test/com/dmdirc/harness/ui/UIClassTestRunner.java Ver arquivo

@@ -22,7 +22,9 @@
22 22
 
23 23
 package com.dmdirc.harness.ui;
24 24
 
25
+import java.lang.reflect.InvocationTargetException;
25 26
 import java.lang.reflect.Method;
27
+import org.junit.BeforeClass;
26 28
 import org.junit.internal.runners.TestClassMethodsRunner;
27 29
 import org.junit.internal.runners.TestMethodRunner;
28 30
 import org.junit.runner.notification.RunNotifier;
@@ -31,6 +33,18 @@ public class UIClassTestRunner extends TestClassMethodsRunner {
31 33
 
32 34
     public UIClassTestRunner(Class<?> arg0) {
33 35
         super(arg0);
36
+
37
+        for (Method method : arg0.getMethods()) {
38
+            if (method.getAnnotation(BeforeClass.class) != null) {
39
+                try {
40
+                    method.invoke(null);
41
+                } catch (InvocationTargetException e) {
42
+                    return;
43
+                } catch (Throwable e) {
44
+                    return;
45
+                }
46
+            }
47
+        }
34 48
     }
35 49
 
36 50
     protected TestMethodRunner createMethodRunner(Object test, Method method, RunNotifier notifier) {

+ 8
- 15
test/com/dmdirc/harness/ui/UIMethodTestRunner.java Ver arquivo

@@ -46,21 +46,7 @@ public class UIMethodTestRunner extends TestMethodRunner {
46 46
 
47 47
     @Override
48 48
     protected void runUnprotected() {
49
-
50
-        for (Method method : test.getClass().getMethods()) {
51
-            System.out.println(method.getName() + " --> " + method.getAnnotation(BeforeClass.class));
52
-            if (method.getAnnotation(BeforeClass.class) != null) {
53
-                try {
54
-                    method.invoke(test);
55
-                } catch (InvocationTargetException e) {
56
-                    addFailure(e.getCause());
57
-                    return;
58
-                } catch (Throwable e) {
59
-                    addFailure(e);
60
-                    return;
61
-                }
62
-            }
63
-        }
49
+        ((UITestIface) test).setUp();
64 50
 
65 51
         boolean retry;
66 52
         int retries = 5;
@@ -84,6 +70,13 @@ public class UIMethodTestRunner extends TestMethodRunner {
84 70
                 addFailure(e);
85 71
             }
86 72
         } while (retry);
73
+
74
+        ((UITestIface) test).tearDown();
75
+    }
76
+
77
+    @Override
78
+    public void runProtected() {
79
+        runUnprotected();
87 80
     }
88 81
 
89 82
 }

Carregando…
Cancelar
Salvar