1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +02:00

There is a new way to mark tests as failing

And by "new" I mean 15 years old.

Part of #117
This commit is contained in:
Jonah Graham 2022-10-27 15:34:10 -04:00
parent 9811767b6a
commit 5cebec6477
3 changed files with 2 additions and 89 deletions

View file

@ -1,72 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2012 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Nov 1, 2004
*/
package org.eclipse.cdt.core.tests;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import junit.framework.TestFailure;
import junit.framework.TestResult;
/**
* Wraps a test case to check for its failure.
* @author aniefer
*/
public class FailingTester extends TestCase {
private TestCase test = null;
private int bugNum = -1;
public FailingTester(TestCase test, int bugNumber) {
this.test = test;
this.bugNum = bugNumber;
String name = "Failing " + test.getName();
if (bugNum > 0) {
name += " [bug " + bugNum + "]";
}
setName(name);
}
public FailingTester(TestCase test) {
this(test, -1);
}
/* (non-Javadoc)
* @see junit.framework.Test#run(junit.framework.TestResult)
*/
@Override
public void run(TestResult result) {
result.startTest(this);
TestResult r = new TestResult();
test.run(r);
if (r.failureCount() == 1) {
TestFailure failure = r.failures().nextElement();
String msg = failure.exceptionMessage();
if (msg != null && msg.startsWith("Method \"" + test.getName() + "\"")) {
result.addFailure(this, new AssertionFailedError(msg));
}
} else if (r.errorCount() == 0 && r.failureCount() == 0) {
String err = "Unexpected success"; //$NON-NLS-1$
if (bugNum != -1)
err += ", bug #" + bugNum; //$NON-NLS-1$
result.addFailure(this, new AssertionFailedError(err));
}
result.endTest(this);
}
}

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.ui.tests.refactoring.rename;
import java.io.StringWriter;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.tests.FailingTester;
import org.eclipse.core.resources.IFile;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@ -25,7 +24,6 @@ import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestSuite;
public class RenameRegressionTests extends RenameTestBase {
public RenameRegressionTests() {
@ -37,20 +35,7 @@ public class RenameRegressionTests extends RenameTestBase {
}
public static Test suite() {
return suite(true);
}
public static Test suite(boolean cleanup) {
TestSuite innerSuite = new TestSuite(RenameRegressionTests.class);
innerSuite.addTest(new FailingTester(new RenameRegressionTests("_testMethod_35_72726"), 72726));
TestSuite suite = new TestSuite("RenameRegressionTests");
suite.addTest(innerSuite);
if (cleanup)
suite.addTest(new RenameRegressionTests("cleanupProject"));
return suite;
return suite(RenameRegressionTests.class, "_");
}
public void testSimpleRename() throws Exception {

View file

@ -30,7 +30,7 @@ import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
/**
* @author markus.schorn@windriver.com
*/
public class RenameTestBase extends RefactoringTests {
public abstract class RenameTestBase extends RefactoringTests {
private static final IProgressMonitor NPM = new NullProgressMonitor();
protected RenameTestBase(String name) {