KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit4 > runner > JUnit4TestLoader


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  * David Saff (saff@mit.edu) - initial API and implementation
10  * (bug 102632: [JUnit] Support for JUnit 4.)
11  *******************************************************************************/

12
13 package org.eclipse.jdt.internal.junit4.runner;
14
15 import org.eclipse.jdt.internal.junit.runner.ITestLoader;
16 import org.eclipse.jdt.internal.junit.runner.ITestReference;
17 import org.eclipse.jdt.internal.junit.runner.RemoteTestRunner;
18
19 public class JUnit4TestLoader implements ITestLoader {
20     
21     public ITestReference[] loadTests(
22             @SuppressWarnings JavaDoc("unchecked") Class JavaDoc[] testClasses, // https://bugs.eclipse.org/bugs/show_bug.cgi?id=164472
23
String JavaDoc testName,
24             String JavaDoc[] failureNames,
25             RemoteTestRunner listener) {
26         
27         ITestReference[] refs= new ITestReference[testClasses.length];
28         for (int i= 0; i < testClasses.length; i++) {
29             Class JavaDoc<?> clazz= testClasses[i];
30             ITestReference ref= createTest(clazz, testName);
31             refs[i]= ref;
32         }
33         return refs;
34     }
35
36     private ITestReference createTest(Class JavaDoc<?> clazz, String JavaDoc testName) {
37         if (clazz == null)
38             return null;
39         if (testName == null)
40             return new JUnit4TestClassReference(clazz);
41         return new JUnit4TestMethodReference(clazz, testName);
42     }
43 }
44
Popular Tags