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.TestCase;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
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.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager;
import org.eclipse.cdt.internal.core.index.provider.ReadOnlyPDOMProviderBridge;
@ -71,10 +71,11 @@ public class AbstractSemanticHighlightingTest extends TestCase {
fTestFilename= testFilename;
}
@Override
protected void setUp() throws Exception {
super.setUp();
String sdkCode=
String sdkCode=
"void SDKFunction();\n"+
"class SDKClass { public: SDKMethod(); };\n\n";
@ -139,6 +140,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
return fTestFilename;
}
@Override
protected void tearDown () throws Exception {
EditorTestHelper.closeEditor(fEditor);
@ -165,19 +167,35 @@ public class AbstractSemanticHighlightingTest extends TestCase {
public static final String LINKED_FOLDER= "resources/semanticHighlighting";
public static final String PROJECT= "SHTest";
public static final String TESTFILE= "/SHTest/src/SHTest.cpp";
private static CEditor fEditor;
private static SourceViewer fSourceViewer;
private String fCurrentHighlighting;
private SemanticHighlightingTestSetup fProjectSetup;
@Override
protected void setUp() throws Exception {
super.setUp();
if (!ResourcesPlugin.getWorkspace().getRoot().exists(new Path(PROJECT))) {
fProjectSetup= new SemanticHighlightingTestSetup(this, TESTFILE);
fProjectSetup.setUp();
}
disableAllSemanticHighlightings();
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) {
assertEquals(expected.length, actual.length);
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 Class THIS= SemanticHighlightingTest.class;
private static final Class<?> THIS= SemanticHighlightingTest.class;
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 {

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.testplugin.CProjectHelper;
import org.eclipse.cdt.ui.tests.BaseUITestCase;
import org.eclipse.cdt.ui.tests.text.MarkOccurrenceTest.MarkOccurrenceTestSetup;
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 class EmptyBundle extends ListResourceBundle {
@Override
protected Object[][] getContents() {
return new Object[0][];
}
@ -55,6 +54,7 @@ public class ShiftActionTest extends BaseUITestCase {
super(test);
}
@Override
protected void setUp() throws Exception {
super.setUp();
@ -65,6 +65,7 @@ public class ShiftActionTest extends BaseUITestCase {
IFile file= EditorTestHelper.createFile(fCProject.getProject(), FILE, "", new NullProgressMonitor());
}
@Override
protected void tearDown () throws Exception {
EditorTestHelper.closeAllEditors();
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() {
return new ShiftTestSetup(new TestSuite(THIS));
}
@ -82,14 +83,15 @@ public class ShiftActionTest extends BaseUITestCase {
private CEditor fEditor;
private SourceViewer fSourceViewer;
private IDocument fDocument;
private MarkOccurrenceTestSetup fProjectSetup;
private ShiftTestSetup fProjectSetup;
/*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
if (!ResourcesPlugin.getWorkspace().getRoot().exists(new Path(PROJECT))) {
fProjectSetup= new MarkOccurrenceTestSetup(this);
fProjectSetup= new ShiftTestSetup(this);
fProjectSetup.setUp();
}
fEditor= (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(PROJECT + '/' + FILE), true);
@ -101,6 +103,7 @@ public class ShiftActionTest extends BaseUITestCase {
/*
* @see junit.framework.TestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception {
if (fProjectSetup != null) {
fProjectSetup.tearDown();