Bug 11689 NPE creating a test case in empty workbench
If you create a project and then a JUnit TestCase when there are no other classes in the image you will get a NullPointerException when you select the browse button on the Test Class entry. STEPS 1) Create a ConfigurableProject 2) Create a JUnit Test class. In the creation dialog select the 3rd browse button. Walkback: java.lang.NullPointerException at org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizardPage.chooseClassToTestTyp e(NewTestCaseCreationWizardPage.java:318) at org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizardPage.classToTestButtonPre ssed(NewTestCaseCreationWizardPage.java:293) at org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizardPage.access$0 (NewTestCaseCreationWizardPage.java:292) at org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizardPage$3.widgetSelected (NewTestCaseCreationWizardPage.java:279) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:85) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:525) at org.eclipse.ui.actions.NewWizardAction.run(NewWizardAction.java:74) at org.eclipse.jface.action.Action.runWithEvent(Action.java:473) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:698) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:777) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:196) at org.eclipse.core.launcher.Main.run(Main.java:555) at org.eclipse.core.launcher.Main.main(Main.java:396)
org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestCaseCreationWizardPage.java
fTestMethods= createdType.getMethods();
		ICompilationUnit cu= createdType.getCompilationUnit();
		cu.save(null, false);
		IResource res= createdType.getCompilationUnit().getUnderlyingResource();
		for (int i= getIndexOfFirstMethod(); i < fTestMethods.length; i++) {
			IMethod method= fTestMethods[i];
			IMarker marker= res.createMarker("org.eclipse.jdt.junit.junit_task"); 
			HashMap attributes= new HashMap(10);
			attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_NORMAL));
			attributes.put(IMarker.MESSAGE, Messages.getFormattedString("NewTestClassWizPage.marker.message",method.getElementName())); 
			ISourceRange markerRange= method.getSourceRange();
			attributes.put(IMarker.CHAR_START, new Integer(markerRange.getOffset()));
			attributes.put(IMarker.CHAR_END, new Integer(markerRange.getOffset()+markerRange.getLength()));
			marker.setAttributes(attributes);
		}
	}
	
	private void validateSuperClass() {
		fMethodStubsButtons.setEnabled(2, true);
		fMethodStubsButtons.setEnabled(3, true);
		String superClassName= getSuperClass();
		if (superClassName != null && !superClassName.equals("") && getPackageFragmentRoot() != null) { 
			try {
				IType type= NewTestCaseCreationWizardPage.resolveClassNameToType(getPackageFragmentRoot().getJavaProject(), getPackageFragment(), superClassName);
				JUnitStatus status = new JUnitStatus();				
				if (type == null) {
					status.setError(Messages.getString("NewTestClassWizPage.error.superclass.not_exist")); 
					fSuperClassStatus= status;
				} else {
					if (type.isInterface()) {