Sfoglia il codice sorgente

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

tags/0.6.3m1rc1
Chris Smith 15 anni fa
parent
commit
bf158d9ba6

+ 0
- 4
test/com/dmdirc/addons/ui_swing/MainFrameTest.java Vedi File

134
         window.menuItemWithPath("Server", "Server settings").requireDisabled();
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 Vedi File

22
 
22
 
23
 package com.dmdirc.harness.ui;
23
 package com.dmdirc.harness.ui;
24
 
24
 
25
+import java.lang.reflect.InvocationTargetException;
25
 import java.lang.reflect.Method;
26
 import java.lang.reflect.Method;
27
+import org.junit.BeforeClass;
26
 import org.junit.internal.runners.TestClassMethodsRunner;
28
 import org.junit.internal.runners.TestClassMethodsRunner;
27
 import org.junit.internal.runners.TestMethodRunner;
29
 import org.junit.internal.runners.TestMethodRunner;
28
 import org.junit.runner.notification.RunNotifier;
30
 import org.junit.runner.notification.RunNotifier;
31
 
33
 
32
     public UIClassTestRunner(Class<?> arg0) {
34
     public UIClassTestRunner(Class<?> arg0) {
33
         super(arg0);
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
     protected TestMethodRunner createMethodRunner(Object test, Method method, RunNotifier notifier) {
50
     protected TestMethodRunner createMethodRunner(Object test, Method method, RunNotifier notifier) {

+ 8
- 15
test/com/dmdirc/harness/ui/UIMethodTestRunner.java Vedi File

46
 
46
 
47
     @Override
47
     @Override
48
     protected void runUnprotected() {
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
         boolean retry;
51
         boolean retry;
66
         int retries = 5;
52
         int retries = 5;
84
                 addFailure(e);
70
                 addFailure(e);
85
             }
71
             }
86
         } while (retry);
72
         } while (retry);
73
+
74
+        ((UITestIface) test).tearDown();
75
+    }
76
+
77
+    @Override
78
+    public void runProtected() {
79
+        runUnprotected();
87
     }
80
     }
88
 
81
 
89
 }
82
 }

Loading…
Annulla
Salva