KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > model > TestCaseElement


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.junit.model;
13
14 import org.eclipse.core.runtime.Assert;
15
16 import org.eclipse.jdt.junit.model.ITestCaseElement;
17
18
19 public class TestCaseElement extends TestElement implements ITestCaseElement {
20
21     private boolean fIgnored;
22
23     public TestCaseElement(TestSuiteElement parent, String JavaDoc id, String JavaDoc testName) {
24         super(parent, id, testName);
25         Assert.isNotNull(parent);
26     }
27     
28     /**
29      * {@inheritDoc}
30      * @see org.eclipse.jdt.junit.model.ITestCaseElement#getTestMethodName()
31      * @see org.eclipse.jdt.internal.junit.runner.MessageIds#TEST_IDENTIFIER_MESSAGE_FORMAT
32      * @see org.eclipse.jdt.internal.junit.runner.MessageIds#IGNORED_TEST_PREFIX
33      */

34     public String JavaDoc getTestMethodName() {
35         String JavaDoc testName= getTestName();
36         int index= testName.indexOf('(');
37         if (index > 0)
38             return testName.substring(0, index);
39         index= testName.indexOf('@');
40         if (index > 0)
41             return testName.substring(0, index);
42         return testName;
43     }
44     
45     /**
46      * {@inheritDoc}
47      * @see org.eclipse.jdt.junit.model.ITestCaseElement#getTestClassName()
48      */

49     public String JavaDoc getTestClassName() {
50         return getClassName();
51     }
52     
53     public void setIgnored(boolean ignored) {
54         fIgnored= ignored;
55     }
56     
57     public boolean isIgnored() {
58         return fIgnored;
59     }
60     
61     public String JavaDoc toString() {
62         return "TestCase: " + getTestClassName() + "." + getTestMethodName() + " : " + super.toString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
63
}
64 }
65
Popular Tags