KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > runner > TestExecution


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  * David Saff (saff@mit.edu) - initial API and implementation
11  * (bug 102632: [JUnit] Support for JUnit 4.)
12  *******************************************************************************/

13
14 package org.eclipse.jdt.internal.junit.runner;
15
16 import java.util.ArrayList JavaDoc;
17 import java.util.Iterator JavaDoc;
18
19 public class TestExecution {
20     private boolean fShouldStop = false;
21
22     private IListensToTestExecutions fExecutionListener;
23
24     private IClassifiesThrowables fClassifier;
25
26     private ArrayList JavaDoc fStopListeners = new ArrayList JavaDoc();
27
28     public TestExecution(IListensToTestExecutions listener,
29             IClassifiesThrowables classifier) {
30         fClassifier = classifier;
31         fExecutionListener = listener;
32     }
33
34     public void run(ITestReference[] suites) {
35         for (int i = 0; i < suites.length; i++) {
36             if (fShouldStop)
37                 return;
38             suites[i].run(this);
39         }
40     }
41
42     public boolean shouldStop() {
43         return fShouldStop;
44     }
45
46     public void stop() {
47         fShouldStop = true;
48         for (Iterator JavaDoc iter = fStopListeners.iterator(); iter.hasNext();) {
49             IStopListener listener = (IStopListener) iter.next();
50             listener.stop();
51         }
52     }
53
54     public IListensToTestExecutions getListener() {
55         return fExecutionListener;
56     }
57
58     public IClassifiesThrowables getClassifier() {
59         return fClassifier;
60     }
61
62     public void addStopListener(IStopListener listener) {
63         fStopListeners.add(listener);
64     }
65 }
66
Popular Tags