Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5ce3c3ba91745cfd0589cae9be101178d2824dc2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*******************************************************************************
 * Copyright (c) 2000, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.debug.jdi.tests;

import java.lang.reflect.Method;
import junit.framework.TestCase;

/**
 * Wrapper to be able to use the JDI tests in a test suite without
 * starting and shutting down the VM after each test.
 */
public class JDITestCase extends TestCase {
	private AbstractJDITest fTest;
	/**
	 * Creates a new test for the given JDI test.
	 * @param test
	 * @param name
	 */
	public JDITestCase(AbstractJDITest test, String name) {
		super(name);
		fTest = test;
	}
	/**
	 * Override to run the test and assert its state.
	 * @exception Throwable if any exception is thrown
	 */
	@Override
	protected void runTest() throws Throwable {
		Method runMethod = null;
		try {
			runMethod = fTest.getClass().getMethod(getName(), new Class[0]);
		} catch (NoSuchMethodException e) {
			e.fillInStackTrace();
			throw e;
		}
		try {
			fTest.verbose("Running " + getName());
			runMethod.invoke(fTest, new Class[0]);
		} catch (java.lang.reflect.InvocationTargetException e) {
			if (e.getTargetException() instanceof NotYetImplementedException)
				System.out.println("\n" + getName() + " is not yet implemented.");
			else {
				e.fillInStackTrace();
				throw e.getTargetException();
			}
		} catch (IllegalAccessException e) {
			e.fillInStackTrace();
			throw e;
		}
	}
	/**
	 * Init tests
	 */
	@Override
	protected void setUp() {
		// Ignore setUp since it is done once for all tests in the test suite
	}
	/**
	 * Tears down the fixture.
	 */
	@Override
	protected void tearDown() {
		// Ignore tearDown since it is done once for all tests in the test suite
	}
	/**
	 * Returns a string representation of the test case
	 * @see junit.framework.TestCase#toString()
	 */
	@Override
	public String toString() {
		return fTest.getClass().getName() + "." + getName() + "()";
	}
}

Back to the top