diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java index 497373f6247..13853724d6a 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java @@ -43,8 +43,8 @@ public class ErrorParserFileMatchingTest extends TestCase { private final static String testName = "FindMatchingFilesTest"; // Default project gets created once then used by all test cases. - private final IProject fProject; - private final String mockErrorParserId; + private IProject fProject = null; + private String mockErrorParserId = null; private ArrayList errorList; private final IMarkerGenerator markerGenerator = new IMarkerGenerator() { @@ -77,20 +77,16 @@ public class ErrorParserFileMatchingTest extends TestCase { */ public ErrorParserFileMatchingTest(String name) { super(name); - IProject project = null; - try { - project = ResourceHelper.createCDTProject(testName); - } catch (Exception e) { - Assert.fail(e.toString()); - } - fProject = project; - Assert.assertNotNull(project); - mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class); } @Override protected void setUp() throws Exception { + if (fProject==null) { + fProject = ResourceHelper.createCDTProject(testName); + Assert.assertNotNull(fProject); + mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class); + } errorList = new ArrayList(); } @@ -114,6 +110,15 @@ public class ErrorParserFileMatchingTest extends TestCase { junit.textui.TestRunner.run(suite()); } + /** + * Adds Error Parser extension to the global repository. + * Note that this function will "pollute" the working environment and + * the error parser will be seen by other test cases as well. + * + * @param shortId - last portion of ID with which error parser will be added. + * @param cl - Error Parser class + * @return - full ID of the error parser (generated by the method). + */ private static String addErrorParserExtension(String shortId, Class cl) { String ext = "" + "" diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserManagerTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserManagerTest.java index 6333de71ec1..155e485e3bc 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserManagerTest.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserManagerTest.java @@ -74,6 +74,7 @@ public class ErrorParserManagerTest extends TestCase { * Example code test the packages in the project * "com.qnx.tools.ide.cdt.core" */ + @Override protected void setUp() throws Exception { /*** * The test of the tests assume that they have a working workspace @@ -106,7 +107,14 @@ public class ErrorParserManagerTest extends TestCase { } }; - epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, null); + String[] errorParsersIds = { + "org.eclipse.cdt.core.MakeErrorParser", + "org.eclipse.cdt.core.GCCErrorParser", + "org.eclipse.cdt.core.GASErrorParser", + "org.eclipse.cdt.core.GLDErrorParser", + "org.eclipse.cdt.core.VCErrorParser", + }; + epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, errorParsersIds); } @@ -115,6 +123,7 @@ public class ErrorParserManagerTest extends TestCase { * * Called after every test case method. */ + @Override protected void tearDown() { // release resources here and clean-up }