1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix individual JUnit test invocations

This commit is contained in:
Anton Leherbauer 2008-05-23 12:44:43 +00:00
parent 583077dbfa
commit b5afa53f38
3 changed files with 31 additions and 10 deletions

View file

@ -18,6 +18,7 @@ import junit.extensions.TestSetup;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
@ -42,7 +43,6 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager; import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager;
import org.eclipse.cdt.internal.core.index.provider.ReadOnlyPDOMProviderBridge; import org.eclipse.cdt.internal.core.index.provider.ReadOnlyPDOMProviderBridge;
@ -71,6 +71,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
fTestFilename= testFilename; fTestFilename= testFilename;
} }
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
@ -139,6 +140,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
return fTestFilename; return fTestFilename;
} }
@Override
protected void tearDown () throws Exception { protected void tearDown () throws Exception {
EditorTestHelper.closeEditor(fEditor); EditorTestHelper.closeEditor(fEditor);
@ -165,19 +167,35 @@ public class AbstractSemanticHighlightingTest extends TestCase {
public static final String LINKED_FOLDER= "resources/semanticHighlighting"; public static final String LINKED_FOLDER= "resources/semanticHighlighting";
public static final String PROJECT= "SHTest"; public static final String PROJECT= "SHTest";
public static final String TESTFILE= "/SHTest/src/SHTest.cpp";
private static CEditor fEditor; private static CEditor fEditor;
private static SourceViewer fSourceViewer; private static SourceViewer fSourceViewer;
private String fCurrentHighlighting; private String fCurrentHighlighting;
private SemanticHighlightingTestSetup fProjectSetup;
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
if (!ResourcesPlugin.getWorkspace().getRoot().exists(new Path(PROJECT))) {
fProjectSetup= new SemanticHighlightingTestSetup(this, TESTFILE);
fProjectSetup.setUp();
}
disableAllSemanticHighlightings(); disableAllSemanticHighlightings();
EditorTestHelper.runEventQueue(500); EditorTestHelper.runEventQueue(500);
} }
@Override
protected void tearDown() throws Exception {
if (fProjectSetup != null) {
fProjectSetup.tearDown();
fProjectSetup= null;
}
super.tearDown();
}
protected void assertEqualPositions(Position[] expected, Position[] actual) { protected void assertEqualPositions(Position[] expected, Position[] actual) {
assertEquals(expected.length, actual.length); assertEquals(expected.length, actual.length);
for (int i= 0, n= expected.length; i < n; i++) { for (int i= 0, n= expected.length; i < n; i++) {

View file

@ -29,10 +29,10 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
private static final boolean PRINT_POSITIONS= false; private static final boolean PRINT_POSITIONS= false;
private static final Class THIS= SemanticHighlightingTest.class; private static final Class<?> THIS= SemanticHighlightingTest.class;
public static Test suite() { public static Test suite() {
return new SemanticHighlightingTestSetup(new TestSuite(THIS), "/SHTest/src/SHTest.cpp"); return new SemanticHighlightingTestSetup(new TestSuite(THIS), TESTFILE);
} }
public void testStaticFieldHighlighting() throws Exception { public void testStaticFieldHighlighting() throws Exception {

View file

@ -28,8 +28,6 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.ui.tests.BaseUITestCase;
import org.eclipse.cdt.ui.tests.text.MarkOccurrenceTest.MarkOccurrenceTestSetup;
import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.editor.CEditor;
/** /**
@ -42,6 +40,7 @@ public class ShiftActionTest extends BaseUITestCase {
private static final String FILE = "shiftTest.c"; private static final String FILE = "shiftTest.c";
private static final class EmptyBundle extends ListResourceBundle { private static final class EmptyBundle extends ListResourceBundle {
@Override
protected Object[][] getContents() { protected Object[][] getContents() {
return new Object[0][]; return new Object[0][];
} }
@ -55,6 +54,7 @@ public class ShiftActionTest extends BaseUITestCase {
super(test); super(test);
} }
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
@ -65,6 +65,7 @@ public class ShiftActionTest extends BaseUITestCase {
IFile file= EditorTestHelper.createFile(fCProject.getProject(), FILE, "", new NullProgressMonitor()); IFile file= EditorTestHelper.createFile(fCProject.getProject(), FILE, "", new NullProgressMonitor());
} }
@Override
protected void tearDown () throws Exception { protected void tearDown () throws Exception {
EditorTestHelper.closeAllEditors(); EditorTestHelper.closeAllEditors();
if (fCProject != null) { if (fCProject != null) {
@ -74,7 +75,7 @@ public class ShiftActionTest extends BaseUITestCase {
} }
} }
private static final Class THIS= ShiftActionTest.class; private static final Class<?> THIS= ShiftActionTest.class;
public static Test suite() { public static Test suite() {
return new ShiftTestSetup(new TestSuite(THIS)); return new ShiftTestSetup(new TestSuite(THIS));
} }
@ -82,14 +83,15 @@ public class ShiftActionTest extends BaseUITestCase {
private CEditor fEditor; private CEditor fEditor;
private SourceViewer fSourceViewer; private SourceViewer fSourceViewer;
private IDocument fDocument; private IDocument fDocument;
private MarkOccurrenceTestSetup fProjectSetup; private ShiftTestSetup fProjectSetup;
/* /*
* @see junit.framework.TestCase#setUp() * @see junit.framework.TestCase#setUp()
*/ */
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
if (!ResourcesPlugin.getWorkspace().getRoot().exists(new Path(PROJECT))) { if (!ResourcesPlugin.getWorkspace().getRoot().exists(new Path(PROJECT))) {
fProjectSetup= new MarkOccurrenceTestSetup(this); fProjectSetup= new ShiftTestSetup(this);
fProjectSetup.setUp(); fProjectSetup.setUp();
} }
fEditor= (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(PROJECT + '/' + FILE), true); fEditor= (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(PROJECT + '/' + FILE), true);
@ -101,6 +103,7 @@ public class ShiftActionTest extends BaseUITestCase {
/* /*
* @see junit.framework.TestCase#tearDown() * @see junit.framework.TestCase#tearDown()
*/ */
@Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
if (fProjectSetup != null) { if (fProjectSetup != null) {
fProjectSetup.tearDown(); fProjectSetup.tearDown();