From: David S. <da...@sa...> - 2009-06-01 17:18:55
|
The latest snapshot build of 4.7 is junit-4.7-SNAPSHOT-20090601-1258. This build upgrades the bundled version of Hamcrest up to 1.2, which has effects on the Matchers used as targets of the assertThat() statement. If anyone can try compiling their pre-4.7 code which uses assertThat against the new build, and can report results, it would be a great help. Share and enjoy, David Saff More detailed notes: - Hamcrest 1.2 is now incorporated. - The following methods from `JUnitMatchers` are deprecated, and moved to `CoreMatchers`: - `JUnitMatchers.hasItem` is now `CoreMatchers.hasItem` - `JUnitMatchers.hasItems` is now `CoreMatchers.hasItems` - `JUnitMatchers.containsString` is now `CoreMatchers.containsString` - Matchers now have more informative mismatch descriptions. For example: @SuppressWarnings("unchecked") @Test public void stringIsAnInteger() { assertThat("identifier", "actual", matches(is(Integer.class))); // prints: // Expected: is an instance of java.lang.Integer // but: \"actual\" is a java.lang.String } - Some matchers have slightly changed type signatures, especially those created by `is()` and `equalTo`. Everything should work, except see `BothTest` for an example of how the `both().and()` and `either().or()` constructs may be affected. To essentially disable type-checking for a matcher expression, use `JUnitMatchers.matches()` (see below) - `JUnitMatchers.isOneOf(...)` is sugar for the situation where you want to specify a finite list of concrete objects that can match. For example: assertThat(3, isOneOf(3, 4)); - `JUnitMatchers.matches()` disables type-checking of a matcher entirely. Goofy example: assertThat(3, matches(containsString("a"))); Real example: assertThat(3, either(matches(is(String.class))).or( matches(is(Integer.class)))); |
From: Stefan B. <ste...@fr...> - 2009-06-02 10:17:53
|
On 2009-06-01, David Saff <da...@sa...> wrote: > If anyone can try compiling their pre-4.7 code which uses assertThat > against the new build, and can report results, it would be a great > help. Apache Gump uses JUnit's trunk for everything it builds, but most of the projects probably do't use assertThat at all. One project that started to fail after you managed to get JUnit's trunk compile on Java6 is xmlunit: http://vmgump.apache.org/gump/public/xmlunit/xmlunit/gump_work/build_xmlunit_xmlunit.html Since I'm the main developer of xmlunit right now, I was just about to ping you anyway. So far I haven't found the time to look into the root cause or even try to find a way of fixing xmlunit's build. Stefan |
From: David S. <da...@sa...> - 2009-06-03 13:25:05
|
Stefan, Logged here: http://github.com/KentBeck/junit/issues#issue/9 I think I may have a solution, by following hamcrest's lead and changing the signature of assertThat. I'll release another snapshot soon you can try. David Saff On Tue, Jun 2, 2009 at 5:44 AM, Stefan Bodewig <ste...@fr...> wrote: > On 2009-06-01, David Saff <da...@sa...> wrote: > >> If anyone can try compiling their pre-4.7 code which uses assertThat >> against the new build, and can report results, it would be a great >> help. > > Apache Gump uses JUnit's trunk for everything it builds, but most of > the projects probably do't use assertThat at all. > > One project that started to fail after you managed to get JUnit's > trunk compile on Java6 is xmlunit: > > http://vmgump.apache.org/gump/public/xmlunit/xmlunit/gump_work/build_xmlunit_xmlunit.html > > Since I'm the main developer of xmlunit right now, I was just about to > ping you anyway. So far I haven't found the time to look into the > root cause or even try to find a way of fixing xmlunit's build. > > Stefan > > > ------------------------------------ > > Yahoo! Groups Links > > <*> To visit your group on the web, go to: > http://groups.yahoo.com/group/junit/ > > <*> Your email settings: > Individual Email | Traditional > > <*> To change settings online go to: > http://groups.yahoo.com/group/junit/join > (Yahoo! ID required) > > <*> To change settings via email: > mailto:jun...@ya... > mailto:jun...@ya... > > <*> To unsubscribe from this group, send an email to: > jun...@ya... > > <*> Your use of Yahoo! Groups is subject to: > http://docs.yahoo.com/info/terms/ > > |
From: Stefan B. <ste...@fr...> - 2009-06-05 11:14:05
|
On 2009-06-03, David Saff <da...@sa...> wrote: > Stefan, > Logged here: > http://github.com/KentBeck/junit/issues#issue/9 > I think I may have a solution, by following hamcrest's lead and > changing the signature of assertThat. I'll release another snapshot > soon you can try. The snapshot still didn't do the trick and I think it is Hamcrest's Is.is(Class<T>) method. The signature changed from Matcher<Object> is(java.lang.Class<?>) to <T> Matcher<? super T> is(Class<T>) I've changed XMLUnit's tests to use IsInstanceOf.instanceOf() explicitly instead of using the is() method and things compile and work correctly with both JUnit 4.6 and the 20090604 snapshot. Note that instanceOf also changed from Matcher<Object> instanceOf(Class<?>) to <T> Matcher<T> instanceOf(Class<?>) but it works (note it is still Class<?> in Hamcrest 1.2). BTW, if I compile the older test code using is() (XMLUnit svn trunk revision 342) <http://xmlunit.svn.sourceforge.net/viewvc/xmlunit/trunk/xmlunit/> against 4.6 and run them with the latests JUnit snapshot things work just fine - it's just the code doesn't compile using the snapshot. Stefan |
From: David S. <da...@sa...> - 2009-07-28 02:06:14
|
Stefan, I think that we changed things back for the final release--let me know if that's the case. Thanks, David Saff On Fri, Jun 5, 2009 at 7:13 AM, Stefan Bodewig<ste...@fr...> wrote: > On 2009-06-03, David Saff <da...@sa...> wrote: > >> Stefan, > >> Logged here: > >> http://github.com/KentBeck/junit/issues#issue/9 > >> I think I may have a solution, by following hamcrest's lead and >> changing the signature of assertThat. I'll release another snapshot >> soon you can try. > > The snapshot still didn't do the trick and I think it is Hamcrest's > Is.is(Class<T>) method. The signature changed from > > Matcher<Object> is(java.lang.Class<?>) > > to > > <T> Matcher<? super T> is(Class<T>) > > I've changed XMLUnit's tests to use IsInstanceOf.instanceOf() > explicitly instead of using the is() method and things compile and > work correctly with both JUnit 4.6 and the 20090604 snapshot. > > Note that instanceOf also changed from > > Matcher<Object> instanceOf(Class<?>) > > to > > <T> Matcher<T> instanceOf(Class<?>) > > but it works (note it is still Class<?> in Hamcrest 1.2). > > BTW, if I compile the older test code using is() (XMLUnit svn trunk > revision 342) > <http://xmlunit.svn.sourceforge.net/viewvc/xmlunit/trunk/xmlunit/> > against 4.6 and run them with the latests JUnit snapshot things work > just fine - it's just the code doesn't compile using the snapshot. > > Stefan > > ------------------------------------------------------------------------------ > OpenSolaris 2009.06 is a cutting edge operating system for enterprises > looking to deploy the next generation of Solaris that includes the latest > innovations from Sun and the OpenSource community. Download a copy and > enjoy capabilities such as Networking, Storage and Virtualization. > Go to: http://p.sf.net/sfu/opensolaris-get > _______________________________________________ > Junit-devel mailing list > Jun...@li... > https://lists.sourceforge.net/lists/listinfo/junit-devel > |
From: Stefan B. <ste...@fr...> - 2009-07-30 15:41:25
|
On 2009-07-28, David Saff <da...@sa...> wrote: > I think that we changed things back for the final release--let me know > if that's the case. Thanks, Is the final release available by now? The download link from junit.org sends me to a Sourceforge page that only has a snapshot I have already tried. [1] Anyway, I have modified xmlunit and with my modification it worked with Hamcrest 1.2 as well as 1.1 (otherwise I would have gotten a failure mail from our friend Apache Gump). I don't intend to switch back to the is(Class) usage since it will only bring us back into trouble if you ever try to use Hamcrest 1.2 again 8-) Thanks Stefan [1] I later found the 4.7 release at Github, you may want to fix the links at junit.org. |
From: David S. <da...@sa...> - 2009-08-06 20:17:28
|
Stefan, Thanks, the links should work now On Thu, Jul 30, 2009 at 11:41 AM, Stefan Bodewig<ste...@fr...> wrote: > On 2009-07-28, David Saff <da...@sa...> wrote: > >> I think that we changed things back for the final release--let me know >> if that's the case. Thanks, > > Is the final release available by now? The download link from junit.org > sends me to a Sourceforge page that only has a snapshot I have already > tried. [1] > > Anyway, I have modified xmlunit and with my modification it worked with > Hamcrest 1.2 as well as 1.1 (otherwise I would have gotten a failure > mail from our friend Apache Gump). > > I don't intend to switch back to the is(Class) usage since it will only > bring us back into trouble if you ever try to use Hamcrest 1.2 again 8-) > > Thanks > > Stefan > > [1] I later found the 4.7 release at Github, you may want to fix > the links at junit.org. > |