<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Redesigning JUnit Asserts</title>
	<atom:link href="http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/feed/" rel="self" type="application/rss+xml" />
	<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/</link>
	<description>Chunky bacon!!</description>
	<lastBuildDate>Wed, 08 Feb 2012 16:00:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Programming Kung Fu &#187; Statistical Unit Tests with ensure4j</title>
		<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/#comment-122</link>
		<dc:creator>Programming Kung Fu &#187; Statistical Unit Tests with ensure4j</dc:creator>
		<pubDate>Thu, 04 Jan 2007 20:54:37 +0000</pubDate>
		<guid isPermaLink="false">http://martin.ankerl.com/?p=70#comment-122</guid>
		<description>[...] As part of another project I am developing ensure4j. The syntax (see the examples here) is working quite nicely, ensure4j is already very useful for internal use. [...]</description>
		<content:encoded><![CDATA[<p>[...] As part of another project I am developing ensure4j. The syntax (see the examples here) is working quite nicely, ensure4j is already very useful for internal use. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: martinus</title>
		<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/#comment-121</link>
		<dc:creator>martinus</dc:creator>
		<pubDate>Thu, 04 Jan 2007 19:50:54 +0000</pubDate>
		<guid isPermaLink="false">http://martin.ankerl.com/?p=70#comment-121</guid>
		<description>Hi Roy, the ensure4j library is shaping up quite nicely. I am using Java 5 and am already using varargs whenever appropriate :)

The ensure() syntax has already proven  to be very useful, e.g. I have added statistical tests that make it possible to e.g. verify the quality of optimizers.

I would love to make this open source, but I have developed it at work while working on another project so I am not sure if I can convince my boss to do this.</description>
		<content:encoded><![CDATA[<p>Hi Roy, the ensure4j library is shaping up quite nicely. I am using Java 5 and am already using varargs whenever appropriate <img src="http://martin.ankerl.com/wp-includes/images/smilies/icon_smile.gif?9d7bd4" alt=':)' class='wp-smiley' /> </p>
<p>The ensure() syntax has already proven  to be very useful, e.g. I have added statistical tests that make it possible to e.g. verify the quality of optimizers.</p>
<p>I would love to make this open source, but I have developed it at work while working on another project so I am not sure if I can convince my boss to do this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roy van Rijn</title>
		<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/#comment-120</link>
		<dc:creator>Roy van Rijn</dc:creator>
		<pubDate>Thu, 04 Jan 2007 13:43:19 +0000</pubDate>
		<guid isPermaLink="false">http://martin.ankerl.com/?p=70#comment-120</guid>
		<description>Oops, forgot a part of my message.
If you put it on sf.net I&#039;d probably use it! I&#039;m a big fan of jUnit and I really like the way you are making it more readable. This could also be usefull in the IT company I work for, maybe some testers could write their own testcases with this.

So please open-source it... and don&#039;t forget to notify me when you do! Btw. the Belgian branch of our company is working on a jUnit project too:
http://unitils.sourceforge.net/

Maybe the two could then be integrated if you(/and them) want.</description>
		<content:encoded><![CDATA[<p>Oops, forgot a part of my message.<br />
If you put it on sf.net I&#8217;d probably use it! I&#8217;m a big fan of jUnit and I really like the way you are making it more readable. This could also be usefull in the IT company I work for, maybe some testers could write their own testcases with this.</p>
<p>So please open-source it&#8230; and don&#8217;t forget to notify me when you do! Btw. the Belgian branch of our company is working on a jUnit project too:<br />
<a href="http://unitils.sourceforge.net/" rel="nofollow">http://unitils.sourceforge.net/</a></p>
<p>Maybe the two could then be integrated if you(/and them) want.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roy van Rijn</title>
		<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/#comment-119</link>
		<dc:creator>Roy van Rijn</dc:creator>
		<pubDate>Thu, 04 Jan 2007 13:38:20 +0000</pubDate>
		<guid isPermaLink="false">http://martin.ankerl.com/?p=70#comment-119</guid>
		<description>If you decide to use Java 5 you should use varargs for the either() / neither(). In case you don&#039;t have experience yet with varargs:

Instead of overloading either() like this:

boolean either(Object e1);
boolean either(Object e1, Object e2);

With varargs:

boolean either(Object... e1);
(this is like passing a array into the function)</description>
		<content:encoded><![CDATA[<p>If you decide to use Java 5 you should use varargs for the either() / neither(). In case you don&#8217;t have experience yet with varargs:</p>
<p>Instead of overloading either() like this:</p>
<p>boolean either(Object e1);<br />
boolean either(Object e1, Object e2);</p>
<p>With varargs:</p>
<p>boolean either(Object&#8230; e1);<br />
(this is like passing a array into the function)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: martinus</title>
		<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/#comment-118</link>
		<dc:creator>martinus</dc:creator>
		<pubDate>Thu, 03 Aug 2006 20:29:07 +0000</pubDate>
		<guid isPermaLink="false">http://martin.ankerl.com/?p=70#comment-118</guid>
		<description>I would like to have static methods because I like the way junit4 uses the import static:
http://www-128.ibm.com/developerworks/java/library/j-junit4.html
this way it would be very easy to use the ensure() in your existing unit tests, just import the methods and you can use them. No need to extend TestCase.

I was also thinking about the containsNeither syntax, but then you quickly get a hell of a lot of different methods, and it is difficult to reuse code.

instead of
ensure(candle).isBurning()
you can use ensure(candle.isBurning()).isTrue()

With the basic checks you can also write
ensure(candle.length()).between(30,34)
so you do not really always need to write custom test classes.</description>
		<content:encoded><![CDATA[<p>I would like to have static methods because I like the way junit4 uses the import static:<br />
<a href="http://www-128.ibm.com/developerworks/java/library/j-junit4.html" rel="nofollow">http://www-128.ibm.com/developerworks/java/library/j-junit4.html</a><br />
this way it would be very easy to use the ensure() in your existing unit tests, just import the methods and you can use them. No need to extend TestCase.</p>
<p>I was also thinking about the containsNeither syntax, but then you quickly get a hell of a lot of different methods, and it is difficult to reuse code.</p>
<p>instead of<br />
ensure(candle).isBurning()<br />
you can use ensure(candle.isBurning()).isTrue()</p>
<p>With the basic checks you can also write<br />
ensure(candle.length()).between(30,34)<br />
so you do not really always need to write custom test classes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens</title>
		<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/#comment-117</link>
		<dc:creator>Jens</dc:creator>
		<pubDate>Thu, 03 Aug 2006 20:01:20 +0000</pubDate>
		<guid isPermaLink="false">http://martin.ankerl.com/?p=70#comment-117</guid>
		<description>Yeah, you&#039;re right! object() wasn&#039;t that good idea!:-)

Why do you need static methods at all? The problem with static methods is that you can&#039;t overwrite them. I thought you would implement a new TestCase class with a method &quot;ensure()&quot;?

I agree with you that you would need too many methods for contains(neither(3,4)). Maybe containsNeither(3,4)?

I&#039;ve still got the feeling that user defined objects are a problem. Of course it would be easy to write my own ensure() but I have much more to do than I have when using JUnit.
E.g. if I have got a class &quot;Candle&quot; and want to test if a Candle object is burning I would do the following with JUnit:
assertTrue(candle.isBurning());
For this test I have to write one class with one method.

If I want to test the same with &quot;ensure(candle).isBurning()&quot; I need at least 2 classes (the test case and the wrapper for Candle) and 2 methods.

Is the benefit of having a nice looking test really worth having to do the double amount of work?</description>
		<content:encoded><![CDATA[<p>Yeah, you&#8217;re right! object() wasn&#8217;t that good idea!:-)</p>
<p>Why do you need static methods at all? The problem with static methods is that you can&#8217;t overwrite them. I thought you would implement a new TestCase class with a method &#8220;ensure()&#8221;?</p>
<p>I agree with you that you would need too many methods for contains(neither(3,4)). Maybe containsNeither(3,4)?</p>
<p>I&#8217;ve still got the feeling that user defined objects are a problem. Of course it would be easy to write my own ensure() but I have much more to do than I have when using JUnit.<br />
E.g. if I have got a class &#8220;Candle&#8221; and want to test if a Candle object is burning I would do the following with JUnit:<br />
assertTrue(candle.isBurning());<br />
For this test I have to write one class with one method.</p>
<p>If I want to test the same with &#8220;ensure(candle).isBurning()&#8221; I need at least 2 classes (the test case and the wrapper for Candle) and 2 methods.</p>
<p>Is the benefit of having a nice looking test really worth having to do the double amount of work?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: martinus</title>
		<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/#comment-116</link>
		<dc:creator>martinus</dc:creator>
		<pubDate>Thu, 03 Aug 2006 13:45:49 +0000</pubDate>
		<guid isPermaLink="false">http://martin.ankerl.com/?p=70#comment-116</guid>
		<description>Hi, thanks for your comment! You are right that this is not really the typical java style.

- object() is not the right choice either, because I am not objecting anything :-)

- The syntax with contains(neither(3,4)) is a bit cleaner, but then I have the problem that I need lots of other static methods. Currently only ensure() needs to be a static method.

I think it should not be difficult to write ensure() methods for user defined objects. Just write the static method ensure(), and then you can reuse the functionality of the other checker implementations. e.g. if you have a special collection you could easily provide an ensure().size() method where you call your own size method but return an already available NumberChecker so that you can call ensure(x).size().is(100);</description>
		<content:encoded><![CDATA[<p>Hi, thanks for your comment! You are right that this is not really the typical java style.</p>
<p>- object() is not the right choice either, because I am not objecting anything <img src="http://martin.ankerl.com/wp-includes/images/smilies/icon_smile.gif?9d7bd4" alt=':-)' class='wp-smiley' /> </p>
<p>- The syntax with contains(neither(3,4)) is a bit cleaner, but then I have the problem that I need lots of other static methods. Currently only ensure() needs to be a static method.</p>
<p>I think it should not be difficult to write ensure() methods for user defined objects. Just write the static method ensure(), and then you can reuse the functionality of the other checker implementations. e.g. if you have a special collection you could easily provide an ensure().size() method where you call your own size method but return an already available NumberChecker so that you can call ensure(x).size().is(100);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Dornieden</title>
		<link>http://martin.ankerl.com/2006/08/02/redesigning-junit-asserts/#comment-115</link>
		<dc:creator>Jens Dornieden</dc:creator>
		<pubDate>Thu, 03 Aug 2006 09:48:08 +0000</pubDate>
		<guid isPermaLink="false">http://martin.ankerl.com/?p=70#comment-115</guid>
		<description>Very interesting idea! That would be a nice way to provide many of the standard checks everyone needs.

What I don&#039;t like is that you kind of &quot;abuse&quot; the methods to make the code look more like plain english:
- the method &quot;ensure&quot; wouldn&#039;t ensure anything but return some wrapper (I guess).
- a method &quot;contains()&quot; without a parameter looks very weird because one would expect the object to test here.

Why don&#039;t you use something like:
object(a).contains(neither(3,4));

In my opinion that wouldn&#039;t be much less readable but would look more like Java.

Another thing that comes to mind: how would you handle user defined objects?

Jens</description>
		<content:encoded><![CDATA[<p>Very interesting idea! That would be a nice way to provide many of the standard checks everyone needs.</p>
<p>What I don&#8217;t like is that you kind of &#8220;abuse&#8221; the methods to make the code look more like plain english:<br />
- the method &#8220;ensure&#8221; wouldn&#8217;t ensure anything but return some wrapper (I guess).<br />
- a method &#8220;contains()&#8221; without a parameter looks very weird because one would expect the object to test here.</p>
<p>Why don&#8217;t you use something like:<br />
object(a).contains(neither(3,4));</p>
<p>In my opinion that wouldn&#8217;t be much less readable but would look more like Java.</p>
<p>Another thing that comes to mind: how would you handle user defined objects?</p>
<p>Jens</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching using disk: basic
Object Caching 419/421 objects using disk: basic

Served from: martin.ankerl.com @ 2012-02-08 22:19:49 -->
