Bug 210486 - [JUnit] Junit 4 fails on Assert.assertEquals when comparing Strings
Summary: [JUnit] Junit 4 fails on Assert.assertEquals when comparing Strings
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M4   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-20 23:40 EST by Bones CLA
Modified: 2007-12-11 07:34 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bones CLA 2007-11-20 23:40:59 EST
Build ID: M20071023-1652

Steps To Reproduce:
Use the following test class:

import junit.framework.Assert;

import org.junit.Test;

public class DummyTest
{
	  @Test
	  public void passingTest() throws Exception {
	    Assert.assertEquals( "expected", "expected" );
	  }

	  @Test
	  public void failingTest() throws Exception {
	    Assert.assertEquals( "expected", "actual" );
	  }
}

Run As->Junit test and you get the following stack trace (in the console - not in the JUnit view):

java.lang.NoSuchMethodError: junit.framework.ComparisonFailure.getExpected()Ljava/lang/String;
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener.testFailure(JUnit4TestListener.java:62)
	at org.junit.runner.notification.RunNotifier$4.notifyListener(RunNotifier.java:96)
	at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:37)
	at org.junit.runner.notification.RunNotifier.fireTestFailure(RunNotifier.java:93)
	at org.junit.internal.runners.MethodRoadie.addFailure(MethodRoadie.java:147)
	at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:106)
	at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
	at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
	at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)





More information:
Looking at the code, I can see that there are calls to getExpected() and getActual() that aren't in the API for ComparisonFailure.

I'm using Eclipse 3.3.1.1.
Comment 1 Frederic Fusier CLA 2007-11-21 03:01:58 EST
Using Eclipse 3.3.1 and importing org.junit. version 4.3.1 in my workspace, I can see the getExpected() and getActual() methods on junit.framework.ComparisonFailure, so I guess the JUnit version you used or you put in your project's buildpath is not valid.

With this configuration, your example works perfectly; I can run the test either as a JUnit or JUnit Plug-in test in a Java project or Plug-in project and got the expected failure on the second test...
Comment 2 Frederic Fusier CLA 2007-12-11 07:34:11 EST
Verified for 3.4M4