| 1 | /* |
| 2 | * JTiger Unit Testing Framework for J2SE 1.5 |
| 3 | * Copyright (C) 2005 Tony Morris |
| 4 | * |
| 5 | * This software is licenced under the |
| 6 | * Common Public Licence version 1.0 |
| 7 | * http://www.opensource.org/licenses/cpl1.0.php |
| 8 | * |
| 9 | * You received a copy of this licence with this software. |
| 10 | */ |
| 11 | package org.jtiger.framework.junit; |
| 12 | |
| 13 | import java.lang.reflect.Method; |
| 14 | |
| 15 | /** |
| 16 | * This implementation of {@link org.jtiger.framework.TestDefinition} is intended to be used to execute test cases that |
| 17 | * have been written using <a href="%junit.url%" target="_blank">the JUnit Test Framework</a>. The implementation is |
| 18 | * passed to the framework by returning an instance from |
| 19 | * {@link org.jtiger.framework.FixturesRunnerConfig#getDefinitionClass()} or by passing the qualified class name as |
| 20 | * {@link org.jtiger.framework.FixturesRunnerMain#ARG_DEFINITION_CLASS the appropriate argument} on the command line to |
| 21 | * {@link org.jtiger.framework.FixturesRunnerMain#main(String[]) the framework main method}. |
| 22 | * |
| 23 | * @author %javadoc.author.tag% |
| 24 | * @version %version%<br/> |
| 25 | * <i>Build Number %build.number%</i><br/> |
| 26 | * <i>Build Time %build.time% CET (GMT + 1)</i> |
| 27 | */ |
| 28 | public final class JUnitTestDefinition implements org.jtiger.framework.TestDefinition |
| 29 | { |
| 30 | private static final String TEST_METHOD_PREFIX = "test"; |
| 31 | |
| 32 | /** |
| 33 | * Create a default instance of <tt>JUnitTestDefinition</tt>. |
| 34 | */ |
| 35 | public JUnitTestDefinition() |
| 36 | { |
| 37 | |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Returns <code>true</code> if the passed method is a test case designed for |
| 42 | * <a href="%junit.url%" target="_blank">the JUnit Test Framework</a>, <code>false</code> otherwise. This means that |
| 43 | * the method name begins with <tt>"test"</tt> . |
| 44 | * |
| 45 | * @param m The method to check if it is a test case designed for |
| 46 | * <a href="%junit.url%" target="_blank">the JUnit Test Framework</a>. |
| 47 | * @return <code>true</code> if the passed method is a test case designed for |
| 48 | * <a href="%junit.url%" target="_blank">the JUnit Test Framework</a>, <code>false</code> otherwise. |
| 49 | */ |
| 50 | public boolean isTest(final Method m) |
| 51 | { |
| 52 | if(m == null) |
| 53 | { |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | final String name = m.getName(); |
| 58 | |
| 59 | return name.startsWith(JUnitTestDefinition.TEST_METHOD_PREFIX); |
| 60 | } |
| 61 | } |