Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 184642 - [JUnit] JUnit plugin can't find test method if the containing class is an inner class.
Summary: [JUnit] JUnit plugin can't find test method if the containing class is an inn...
Status: RESOLVED DUPLICATE of bug 178503
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-29 17:11 EDT by Joni Freeman CLA
Modified: 2007-04-30 05:23 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joni Freeman CLA 2007-04-29 17:11:08 EDT
Build ID: I20070323-1616

Steps To Reproduce:
1. Create a test where test method is in inner class:

public class SomeContainerClass {
    public static class Innerclass {
        @Test
        public void test() {            
        }        
    }
}

2. Run it as JUnit test from Outline view where inner class can be selected.

3. Open JUnit result tab. Select 'test' method and run it from context menu.


More information:
We are developing a BDD framework on top of JUnit (see http://www.jdave.org/examples.html). It organizes tests using inner classes. We can run them with JUnit4 runners when annotating with @RunWith(JDaveRunner.class) but trying to run individual tests from JUnit tab fails. For instance,
if a test method is in inner class example.Foo$Bar, an error "The input type of lauch configuration does not exists" is displayed. The reason is that javaProject.findType(testTypeName); returns null when testTypeName is 'example.Foo$Bar'. This is the snippet from JUnit plugin code which gets executed:

        private final IJavaElement getTestTarget(ILaunchConfiguration configuration, IJavaProject javaProject) throws CoreException {
     ....
                String testTypeName= configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, ""); //$NON-NLS-1$
                if (testTypeName.length() != 0) {
                        testTypeName= performStringSubstitution(testTypeName);
                        IType type= javaProject.findType(testTypeName);
                        if (type != null) {
                                return type;
                        }
                }
                informAndAbort(JUnitMessages.JUnitLaunchConfigurationDelegate_input_type_does_not_exist, null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE);
                return null; // not reachable
        }
Comment 1 Olivier Thomann CLA 2007-04-29 19:18:56 EDT
Move to JDT/UI
Comment 2 Martin Aeschlimann CLA 2007-04-30 05:23:12 EDT

*** This bug has been marked as a duplicate of bug 178503 ***