<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>The Green Bar</title>
	<link>http://greenbar.saff.net</link>
	<description>Testing the spirits since 2008</description>
	<pubDate>Sat, 14 Nov 2009 13:18:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
	<language>en</language>
			<item>
		<title>Back to blogger</title>
		<link>http://greenbar.saff.net/?p=19</link>
		<comments>http://greenbar.saff.net/?p=19#comments</comments>
		<pubDate>Sat, 14 Nov 2009 12:57:25 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=19</guid>
		<description><![CDATA[I&#8217;ve gotten a little too fed up with trying to post code in wordpress, and have been wanting to try eating Google&#8217;s own dogfood and use blogger.com.  So, let&#8217;s continue the conversation there:
http://saffgreenbar.blogspot.com
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gotten a little too fed up with trying to post code in wordpress, and have been wanting to try eating Google&#8217;s own dogfood and use blogger.com.  So, let&#8217;s continue the conversation there:</p>
<p><a href="http://saffgreenbar.blogspot.com">http://saffgreenbar.blogspot.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=19</wfw:commentRss>
		</item>
		<item>
		<title>Rules in JUnit 4.7</title>
		<link>http://greenbar.saff.net/?p=18</link>
		<comments>http://greenbar.saff.net/?p=18#comments</comments>
		<pubDate>Thu, 16 Jul 2009 18:39:54 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=18</guid>
		<description><![CDATA[All,
JUnit 4.7 will include a new mechanism for changing the behavior and
interpretation of test methods.  We are calling this feature Rules
(replacing the earlier name Interceptors).  You can download a
snapshot of this release.  We are planning no new
feature for this version, and once the tagged bugs are resolved, we will issue an
official release candidate, but early [...]]]></description>
			<content:encoded><![CDATA[<p>All,</p>
<p>JUnit 4.7 will include a new mechanism for changing the behavior and<br />
interpretation of test methods.  We are calling this feature Rules<br />
(replacing the earlier name <a href="http://greenbar.saff.net/?p=14">Interceptors</a>).  You can <a href="http://github.com/KentBeck/junit/downloads">download</a> a<br />
snapshot of this release.  We are planning no new<br />
feature for this version, and once the <a href="http://github.com/KentBeck/junit/issues/labels/4.7">tagged bugs</a> are resolved, we will issue an<br />
official release candidate, but early feedback is very, very welcome.</p>
<p>There are already rules you&#8217;re probably familiar with from way back in<br />
JUnit 4.0:</p>
<ul>
<li>The fundamental rule of JUnit: a test method is executed on a new<br />
instance of its declaring class.  It passes if and only if it<br />
completes without throwing an exception.</li>
<li>The Before rule: a @Test method is preceded by all @Before methods<br />
in the same class.</li>
<li>The After rule: a @Test method is followed by all @After methods in<br />
the same class.</li>
<li>The timeout= rule: if a @Test annotation has a timeout= property, it<br />
fails if it does not complete in under the given number of<br />
milliseconds</li>
<li>The expected= rule: if a @Test annotation has an expected= property,<br />
it passes if it throws an exception of the given class name, and fails<br />
otherwise.</li>
</ul>
<p>Starting with 4.7, you can add additional rules to methods in a class<br />
by declaring public fields in the class annotated with @Rule.  For<br />
example, here&#8217;s a test that uses the TemporaryFolder rule (&#8221;All files<br />
created in the temporary folder during the test are deleted after the<br />
test completes.&#8221;):</p>
<pre>
 public static class HasTempFolder {
   @Rule
   public TemporaryFolder folder= new TemporaryFolder();

   @Test
   public void testUsingTempFolder() throws IOException {
     File createdFile= folder.newFile("myfile.txt");
     File createdFolder= folder.newFolder("subfolder");
     // ...
   }
 }</pre>
<p>We&#8217;re including implementations of the following Rules:</p>
<ul>
<li> TemporaryFolder: delete temp files after test completion</li>
<li> ExternalResource: reliably set up and tear down an arbitrary external resource</li>
<li> ErrorCollector: collect multiple assertion failures per test method, and report all at the end</li>
<li> Verifier: turn a passing test to failing if an arbitrary condition is not met (all expected mock-object calls made, no ERROR lines in the logs)</li>
<li> TestWatchman: Perform an additional task before and after each test (a custom log, for example)</li>
<li> TestName: remember the name of each test method, and make it available during the test execution.</li>
<li> Timeout: like the timeout= rule, but applies to all methods in a class, and can take a run-time value.</li>
<li> ExpectedException: like the expected= rule, but can check exception messages, and other arbitrary assertions.</li>
</ul>
<p>For more on using these rules, please see the <a href="http://github.com/dsaff/junit/blob/99a84a542f2ac532a8425fa0a77884902b1c01b0/doc/ReleaseNotes4.7.txt">release notes</a>.</p>
<p>In addition, you can implement your own Rules by implementing the<br />
MethodRule interface.  Here&#8217;s a Rule that marks all tests as passing,<br />
as long as I&#8217;m the one running them:</p>
<pre>
public class DavidsAlwaysRight implements MethodRule {
       public Statement apply(Statement base, FrameworkMethod method, Object target) {
               if ("saff".equals(System.getenv("USER")))
                       return alwaysSuccess();
               else
                       return base;
       }

       private Statement alwaysSuccess() {
               return new Statement() {
                       @Override
                       public void evaluate() throws Throwable {
                               // do nothing: always success!
                       }
               };
       }
}</pre>
<p>While you&#8217;re here, don&#8217;t forget the <a href="http://www.cafepress.com/3riversinst">T-shirt.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=18</wfw:commentRss>
		</item>
		<item>
		<title>JUnit 4.7: Interceptors: expected exceptions</title>
		<link>http://greenbar.saff.net/?p=17</link>
		<comments>http://greenbar.saff.net/?p=17#comments</comments>
		<pubDate>Wed, 27 May 2009 04:49:10 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=17</guid>
		<description><![CDATA[In the latest snapshot build of JUnit 4.7, we&#8217;ve re-implemented expected exceptions using Interceptors.  Share and Enjoy!

	public static class HasExpectedException {
		@Interceptor
		public ExpectedException thrown= new ExpectedException();

		@Test
		public void throwsNothing() {

		}

		@Test
		public void throwsNullPointerException() {
			thrown.expect(NullPointerException.class);
			throw new NullPointerException();
		}

		@Test
		public void throwsNullPointerExceptionWithMessage() {
			thrown.expect(NullPointerException.class);
			thrown.expectMessage("happened?");
			throw new NullPointerException("What happened?");
		}
	}

]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://github.com/KentBeck/junit/downloads">latest snapshot build</a> of JUnit 4.7, we&#8217;ve re-implemented expected exceptions using <a href="http://www.threeriversinstitute.org/blog/?p=155">Interceptors</a>.  Share and Enjoy!</p>
<pre>
	public static class HasExpectedException {
		@Interceptor
		public ExpectedException thrown= new ExpectedException();

		@Test
		public void throwsNothing() {

		}

		@Test
		public void throwsNullPointerException() {
			thrown.expect(NullPointerException.class);
			throw new NullPointerException();
		}

		@Test
		public void throwsNullPointerExceptionWithMessage() {
			thrown.expect(NullPointerException.class);
			thrown.expectMessage("happened?");
			throw new NullPointerException("What happened?");
		}
	}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=17</wfw:commentRss>
		</item>
		<item>
		<title>Getting the name of the currently-running test method</title>
		<link>http://greenbar.saff.net/?p=15</link>
		<comments>http://greenbar.saff.net/?p=15#comments</comments>
		<pubDate>Tue, 12 May 2009 04:04:06 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=15</guid>
		<description><![CDATA[One of the most common requests since JUnit 4.0 was released has been to restore a somewhat accidental feature of JUnit 3.8.  Since, in 3.8, the same object handled test execution and test lifetime management, a test method had access to the getName() method of TestCase, which was internally used for reporting.  Many extenders used [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most common requests since JUnit 4.0 was released has been to restore a somewhat accidental feature of JUnit 3.8.  Since, in 3.8, the same object handled test execution and test lifetime management, a test method had access to the getName() method of TestCase, which was internally used for reporting.  Many extenders used this fact to build informed lightweight logging functions.  In JUnit 4.0, this accidental feature was not replicated, which made it difficult to port some of these logging routines.</p>
<p>In the <a href="https://sourceforge.net/project/showfiles.php?group_id=15278&amp;package_id=226053&amp;release_id=682045">latest snapshot</a> of JUnit 4.7, we&#8217;ve re-introduced this feature, by way of <a href="http://greenbar.saff.net/?p=14">Interceptors</a>.  It looks like this:</p>
<pre>    @RunWith(Interceptors.class)
    public class NameInterceptorTest {
        @Interceptor public TestName name = new TestName();

        @Test public void testA() {
            assertEquals("testA", name.getMethodName());
        }

        @Test public void testB() {
            assertEquals("testB", name.getMethodName());
        }
    }</pre>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=15</wfw:commentRss>
		</item>
		<item>
		<title>Interceptors in JUnit 4.7</title>
		<link>http://greenbar.saff.net/?p=14</link>
		<comments>http://greenbar.saff.net/?p=14#comments</comments>
		<pubDate>Tue, 05 May 2009 20:16:47 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=14</guid>
		<description><![CDATA[For both of you that read this blog, and haven&#8217;t already seen it, there&#8217;s some fun stuff brewing in JUnit 4.7.
]]></description>
			<content:encoded><![CDATA[<p>For both of you that read this blog, and haven&#8217;t already seen it, there&#8217;s some <a href="http://www.threeriversinstitute.org/blog/?p=155" title="JUnit Max blog">fun stuff brewing</a> in JUnit 4.7.</p>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=14</wfw:commentRss>
		</item>
		<item>
		<title>JUnit self-test wordle</title>
		<link>http://greenbar.saff.net/?p=13</link>
		<comments>http://greenbar.saff.net/?p=13#comments</comments>
		<pubDate>Thu, 04 Dec 2008 02:32:47 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=13</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.wordle.net/gallery/wrdl/359579/JUnit_Tests" title="Wordle: JUnit Tests"><img src="http://www.wordle.net/thumb/wrdl/359579/JUnit_Tests" style="border: 1px solid #dddddd; padding: 4px" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=13</wfw:commentRss>
		</item>
		<item>
		<title>Google Book Search settlement</title>
		<link>http://greenbar.saff.net/?p=12</link>
		<comments>http://greenbar.saff.net/?p=12#comments</comments>
		<pubDate>Tue, 28 Oct 2008 15:05:15 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=12</guid>
		<description><![CDATA[I had the privilege of spending a bit of time building a couple small testing tools to help some hard-working engineers and negotiators build a very interesting future:
http://books.google.com/agreement 
]]></description>
			<content:encoded><![CDATA[<p>I had the privilege of spending a bit of time building a couple small testing tools to help some hard-working engineers and negotiators build a very interesting future:</p>
<p><a href="http://books.google.com/agreement">http://books.google.com/agreement </a></p>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=12</wfw:commentRss>
		</item>
		<item>
		<title>Overriding the default Runner.</title>
		<link>http://greenbar.saff.net/?p=11</link>
		<comments>http://greenbar.saff.net/?p=11#comments</comments>
		<pubDate>Mon, 27 Oct 2008 16:10:29 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=11</guid>
		<description><![CDATA[If you are running your JUnit 4.5 tests with a direct call to JUnitCore.run, you can override the default runner (BlockJUnit4ClassRunner) used to run tests that don&#8217;t otherwise have a @RunWith annotation:

RunnerBuilder builder = new AllDefaultPossibilitiesBuilder() { 
  @Override protected JUnit4Builder junit4Builder() {
    return new JUnit4Builder() {
      [...]]]></description>
			<content:encoded><![CDATA[<p>If you are running your JUnit 4.5 tests with a direct call to <tt>JUnitCore.run</tt>, you can override the default runner (<tt>BlockJUnit4ClassRunner</tt>) used to run tests that don&#8217;t otherwise have a <tt>@RunWith</tt> annotation:</p>
<pre>
RunnerBuilder builder = new AllDefaultPossibilitiesBuilder() { 
  @Override protected JUnit4Builder junit4Builder() {
    return new JUnit4Builder() {
      @Override public Runner runnerForClass(Class testClass) throws Throwable {
        return new MyCustomJUnit4ClassRunner(testClass);
      }
    };
  }
}

new JUnitCore().run(new Suite(AllMyTests.class, builder));</pre>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=11</wfw:commentRss>
		</item>
		<item>
		<title>Spaces flipping with X11 in OS X</title>
		<link>http://greenbar.saff.net/?p=8</link>
		<comments>http://greenbar.saff.net/?p=8#comments</comments>
		<pubDate>Wed, 10 Sep 2008 20:17:49 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=8</guid>
		<description><![CDATA[Say you are using your MacBook to run Eclipse and some xterms from a Linux box through X11, and you distribute your X11 windows to different spaces.  (You&#8217;re probably using NX, so that you aren&#8217;t motivated by latency to throw a cat out the window after every mouse click&#8230;)  Every few moments, your monitor suddenly [...]]]></description>
			<content:encoded><![CDATA[<p>Say you are using your MacBook to run Eclipse and some xterms from a Linux box through X11, and you distribute your X11 windows to different spaces.  (You&#8217;re probably using <a href="http://www.nomachine.com/">NX</a>, so that you aren&#8217;t motivated by latency to throw a cat out the window after every mouse click&#8230;)  Every few moments, your monitor suddenly and violently flips to what feels like a random space.</p>
<p>I&#8217;m lucky enough to sit near Matthew Gray, who brainstormed this solution:</p>
<p>The combination of X11 + <span class="nfakPe">Spaces</span> treats the UI Layer on which tooltips appear as a separate application: if you move <span class="nfakPe">Eclipse</span>, but not the tooltips layer, <span class="nfakPe">Spaces</span> will flip to the old space every time it even thinks about displaying a tooltip (sometimes, it appears, even without any actual tooltip being shown).  This is easy to miss, since the tooltip will go away as soon as you move the mouse.</p>
<p>The fix is one of those things that should never work, but does.  It also requires some skill.  Move the mouse to a place in the <span class="nfakPe">Eclipse</span> window that should pop up a tooltip.  Keep the mouse very still while your Mac flips to the new space.  Now, without moving the mouse, press F8 to Show <span class="nfakPe">Spaces</span> (if you still have the default keys enabled).  Now, carefully pick up the tool tip (which should still be showing, but very small), and drag it into the same space as <span class="nfakPe">Eclipse</span>.</p>
<p>Of course, it would be great if <span class="nfakPe">X11</span> + OS X could work out a better way to play together, but this works for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=8</wfw:commentRss>
		</item>
		<item>
		<title>Checking Exceptions with Theories</title>
		<link>http://greenbar.saff.net/?p=10</link>
		<comments>http://greenbar.saff.net/?p=10#comments</comments>
		<pubDate>Tue, 09 Sep 2008 21:31:44 +0000</pubDate>
		<dc:creator>David Saff</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://greenbar.saff.net/?p=10</guid>
		<description><![CDATA[Robert Rees was astute enough to point out that it can be difficult to combine the expected-exception feature of JUnit 4 with Theories.  What if we want to say that any Comparable in our system should throw a null pointer exception if compared with null?  (By the way, it appears this is neither required nor [...]]]></description>
			<content:encoded><![CDATA[<p>Robert Rees was astute enough to point out that it can be difficult to combine the expected-exception feature of JUnit 4 with Theories.  What if we want to say that any Comparable in our system should throw a null pointer exception if compared with null?  (By the way, it appears this is neither required nor disallowed by the Comparable contract.)</p>
<p>The current answer is a bit ugly: you need to combine the <code>@Test</code> and <code>@Theory</code> annotations:</p>
<pre>
@Theory @Test(expected=NullPointerException.class)
public void compareToNullThrowsNpe(Comparable c) {
   c.compareTo(null);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://greenbar.saff.net/?feed=rss2&amp;p=10</wfw:commentRss>
		</item>
	</channel>
</rss>
