arashja / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

Change of signature of equalTo in Hamcrest 1.2 breaks common jMock usage #86

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This works with Hamcrest 1.1, but doesn't compile with 1.2:

import static org.hamcrest.Matchers.*;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(JMock.class)
public class JMockTest {
  public static interface ITest {
    void method(String arg);
  }

  Mockery context = new Mockery();

  @Test
  public void test() {
    final ITest mock = context.mock(ITest.class);

    context.checking(new Expectations(){{
      oneOf(mock).method(with(equalTo("Hello")));
    }});

    mock.method("Hello");
  }
}

The equalTo can be omitted in jMock 2.5, but it still creates extra work
when upgrading.

Original issue reported on code.google.com by petur...@gmail.com on 3 Jun 2009 at 11:14

GoogleCodeExporter commented 8 years ago
In 1.2, the signature is:

  public static <T> Matcher<? super T> equalTo(T operand)

against, in 1.1:

  public static <T> Matcher<T> equalTo(T operand)

What is the value of this change? Surely it's better to be more specific about 
the
type being returned? Since a Matcher<T> matches the type Matcher<? super T>, I 
can't
see reverting the change breaking the code.

Original comment by mikerwil...@yahoo.co.uk on 28 Jun 2009 at 10:23

GoogleCodeExporter commented 8 years ago
This issue seems to have turned off the JUnit team from further Hamcrest 
support, too:

http://github.com/KentBeck/junit/issuesearch?state=open&q=hamcrest#issue/36
http://github.com/KentBeck/junit/raw/23ffc6baf5768057e366e183e53f4dfa86fbb005/do
c/Relea
seNotes4.7.txt

Do you have any plans to reintroduce 1.1 compatibility, or will the 1.2 version 
be kept 
from now on?

Original comment by edbran...@gmail.com on 8 Mar 2010 at 2:03

GoogleCodeExporter commented 8 years ago
tagging

Original comment by t.denley on 12 May 2012 at 10:53