Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 236467ba6e3b18e1b09b49baed1e30c10cc845c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*******************************************************************************
 * Copyright (c) 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

/*
 * Created on Nov 1, 2004
 */
package org.eclipse.cdt.core.tests;

import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestResult;


/**
 * @author aniefer
 */
public class FailingTest implements Test {
    private Test test = null;
    private int bugNum = -1;
    public FailingTest( Test test, int bugNumber ){
        this.test = test;
        this.bugNum = bugNumber;
    }
    public FailingTest( Test test ){
        this.test = test;
    }
    /* (non-Javadoc)
     * @see junit.framework.Test#countTestCases()
     */
    public int countTestCases() {
        return 1;
    }
    /* (non-Javadoc)
     * @see junit.framework.Test#run(junit.framework.TestResult)
     */
    public void run( TestResult result ) {
        result.startTest( test );
        
        TestResult r = new TestResult();
        test.run( r );
        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( test, new AssertionFailedError( err ) );
        }
        
        result.endTest( test );
    }
}

Back to the top