Method is ambiguous error [message #259068] |
Fri, 13 March 2009 12:37  |
Eclipse User |
|
|
|
I imported a project from my 3.4.1 workspace into a new workspace for
I20090312-2000. JDT doesn't seem to like one of my unit tests anymore.
Here is a similar snippet that compiles in 3.4.1 but not 3.5
@Test
public void ambiguous() {
int i = 1;
assertEquals(i, getBoxed());
}
private Integer getBoxed() {
return Integer.valueOf(1);
}
"The method assertEquals(Object, Object) is ambiguous for the type
AmbiguousTests"
Is there a preference to control this particular error? Perhaps
something I had set in 3.4 that I don't have set in my new workspace..
Thanks
Ben
|
|
|
Re: Method is ambiguous error [message #259076 is a reply to message #259068] |
Fri, 13 March 2009 12:49  |
Eclipse User |
|
|
|
Originally posted by: mauro.molinari.cardinis.com
Ben Vitale ha scritto:
> I imported a project from my 3.4.1 workspace into a new workspace for
> I20090312-2000. JDT doesn't seem to like one of my unit tests anymore.
> Here is a similar snippet that compiles in 3.4.1 but not 3.5
>
> @Test
> public void ambiguous() {
> int i = 1;
> assertEquals(i, getBoxed());
> }
>
> private Integer getBoxed() {
> return Integer.valueOf(1);
> }
>
>
> "The method assertEquals(Object, Object) is ambiguous for the type
> AmbiguousTests"
>
> Is there a preference to control this particular error? Perhaps
> something I had set in 3.4 that I don't have set in my new workspace..
>
> Thanks
> Ben
It's JUnit 4.4 (or later) that introduces a new overload of assertEquals
that make a call like yours ambiguous.
To avoid the problem, make sure that you either call
assertEquals(Object, Object) (by passing two Integers) or
assertEquals(int, int) (by passing two ints).
Eclipse 3.4 embeds JUnit 4.3.1, while the new 3.5 embeds JUnit 4.5 (if I
remember well).
Mauro.
|
|
|
Powered by
FUDForum. Page generated in 0.03250 seconds