<?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: Code Tests As Code Tutorials</title>
	<atom:link href="http://paul-m-jones.com/archives/82/feed" rel="self" type="application/rss+xml" />
	<link>http://paul-m-jones.com/archives/82?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=code-tests-as-examples</link>
	<description>It&#039;s not enough to be smart; you have to actually know things.</description>
	<lastBuildDate>Wed, 16 May 2012 17:27:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: Alexandre Quessy</title>
		<link>http://paul-m-jones.com/archives/82/comment-page-1#comment-1901</link>
		<dc:creator>Alexandre Quessy</dc:creator>
		<pubDate>Tue, 11 Jan 2005 23:37:43 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=82#comment-1901</guid>
		<description>Nice to see that a little comment can generate thoughts somewhere else in the world ! Cyberspace is so small.</description>
		<content:encoded><![CDATA[<p>Nice to see that a little comment can generate thoughts somewhere else in the world ! Cyberspace is so small.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian</title>
		<link>http://paul-m-jones.com/archives/82/comment-page-1#comment-805</link>
		<dc:creator>Sebastian</dc:creator>
		<pubDate>Fri, 10 Dec 2004 11:46:51 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=82#comment-805</guid>
		<description>I have worked in a project where it was the case that we needed to document a interface to stored procedures in a very complex database for a 3rd party acessing here.
So the tests where a) documentation and b) used as integration tests when moving from a dev. server to the live system. 
As the real world bites hard, things tend not to work when you need it and my own experience was here that one documentation and test suite spared a lot of discussions and research on what does not work in which subsystem. 
Systems which are testable tend to follow rules of low coupling and cohesion as simpler they are to test ... those things are connected.
Whats automatable is simple .....</description>
		<content:encoded><![CDATA[<p>I have worked in a project where it was the case that we needed to document a interface to stored procedures in a very complex database for a 3rd party acessing here.<br />
So the tests where a) documentation and b) used as integration tests when moving from a dev. server to the live system.<br />
As the real world bites hard, things tend not to work when you need it and my own experience was here that one documentation and test suite spared a lot of discussions and research on what does not work in which subsystem.<br />
Systems which are testable tend to follow rules of low coupling and cohesion as simpler they are to test &#8230; those things are connected.<br />
Whats automatable is simple &#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Travis Swicegood</title>
		<link>http://paul-m-jones.com/archives/82/comment-page-1#comment-749</link>
		<dc:creator>Travis Swicegood</dc:creator>
		<pubDate>Thu, 09 Dec 2004 21:30:42 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=82#comment-749</guid>
		<description>Here&#039;s a sample of one of the tests I have running on a class called Filter.  Filter takes a key, value, and a valid Comparison object and creates a Filter for filtering results.  Anyhow, here&#039;s one of the tests:

&lt;code&gt;   /**
    * Test to insure that filter is providing information back properly.
    */
    public function test_GoodReturn()
    {
        $test = new Filter(&#039;keyName&#039;, &#039;valueName&#039;, new Comparison(&#039;=&#039;));
        $this-&gt;assertTrue($test-&gt;isValid());
        $this-&gt;assertEqual($test-&gt;__toString(), &#039;keyName = valueName&#039;);
        
        $test-&gt;setValueDelimiter(&#039;&quot;&#039;);
        $this-&gt;assertEqual($test-&gt;__toString(), &#039;keyName = &quot;valueName&quot;&#039;);
        
        $test-&gt;setKeyDelimiter(&#039;`&#039;);
        $test-&gt;setValueDelimiter(&#039;&#039;);
        $this-&gt;assertEqual($test-&gt;__toString(), &#039;`keyName` = valueName&#039;);
        
        $test-&gt;setKeyDelimiter(&#039;&#039;);
        $test-&gt;setKey(&#039;newKey&#039;);
        $this-&gt;assertEqual($test-&gt;__toString(), &#039;newKey = valueName&#039;);
        
        $test-&gt;setValue(&#039;newValue&#039;);
        $this-&gt;assertEqual($test-&gt;__toString(), &#039;newKey = newValue&#039;);
    }&lt;/code&gt;

As the code progresses, I think it&#039;s fairly straight forward as to what is happening.  All of the &quot;$this&quot; references point to the Filter_Test which extends UnitTestCaseExt - my personal flavor of Simple Test - which contains all of the assert* methods.  If you know what assert() is, though, it&#039;s easy to assume that assertEqual() is checking to insure two values are equal then the rest of it is just a matter of reading the code to see how it&#039;s working.

I would check out &lt;a href=&quot;http://www.lastcraft.com/blog/&quot;&gt;Marcus Baker&lt;/a&gt;&#039;s article on &lt;a href=&quot;http://www.developerspot.com/tutorials/php/test-driven-development/page1.html&quot;&gt;Test Drive Development&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a sample of one of the tests I have running on a class called Filter.  Filter takes a key, value, and a valid Comparison object and creates a Filter for filtering results.  Anyhow, here&#8217;s one of the tests:</p>
<p><code>   /**<br />
    * Test to insure that filter is providing information back properly.<br />
    */<br />
    public function test_GoodReturn()<br />
    {<br />
        $test = new Filter('keyName', 'valueName', new Comparison('='));<br />
        $this->assertTrue($test->isValid());<br />
        $this->assertEqual($test->__toString(), 'keyName = valueName');</p>
<p>        $test->setValueDelimiter('"');<br />
        $this->assertEqual($test->__toString(), 'keyName = "valueName"');</p>
<p>        $test->setKeyDelimiter('`');<br />
        $test->setValueDelimiter('');<br />
        $this->assertEqual($test->__toString(), '`keyName` = valueName');</p>
<p>        $test->setKeyDelimiter('');<br />
        $test->setKey('newKey');<br />
        $this->assertEqual($test->__toString(), 'newKey = valueName');</p>
<p>        $test->setValue('newValue');<br />
        $this->assertEqual($test->__toString(), 'newKey = newValue');<br />
    }</code></p>
<p>As the code progresses, I think it&#8217;s fairly straight forward as to what is happening.  All of the &#8220;$this&#8221; references point to the Filter_Test which extends UnitTestCaseExt &#8211; my personal flavor of Simple Test &#8211; which contains all of the assert* methods.  If you know what assert() is, though, it&#8217;s easy to assume that assertEqual() is checking to insure two values are equal then the rest of it is just a matter of reading the code to see how it&#8217;s working.</p>
<p>I would check out <a href="http://www.lastcraft.com/blog/">Marcus Baker</a>&#8216;s article on <a href="http://www.developerspot.com/tutorials/php/test-driven-development/page1.html">Test Drive Development</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harry Fuecks</title>
		<link>http://paul-m-jones.com/archives/82/comment-page-1#comment-748</link>
		<dc:creator>Harry Fuecks</dc:creator>
		<pubDate>Thu, 09 Dec 2004 21:29:21 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=82#comment-748</guid>
		<description>I&#039;m deep in the &quot;write automated tests&quot; camp simply out of laziness - they give me an absolute result immediately that I can re-run again and again, which I find extremely valuable for development. Granted they aren&#039;t friendly if you&#039;re not familiar with unit testing and, generally, don&#039;t serve as practical examples. Prefer to write examples seperately.

But can see where you&#039;re coming from and the value of it. Perhaps the phpt tests make a good compromise.</description>
		<content:encoded><![CDATA[<p>I&#8217;m deep in the &#8220;write automated tests&#8221; camp simply out of laziness &#8211; they give me an absolute result immediately that I can re-run again and again, which I find extremely valuable for development. Granted they aren&#8217;t friendly if you&#8217;re not familiar with unit testing and, generally, don&#8217;t serve as practical examples. Prefer to write examples seperately.</p>
<p>But can see where you&#8217;re coming from and the value of it. Perhaps the phpt tests make a good compromise.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://paul-m-jones.com/archives/82/comment-page-1#comment-746</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Thu, 09 Dec 2004 18:55:43 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=82#comment-746</guid>
		<description>PHP&#039;s .phpt (php tests) are extremely simple, and don&#039;t suffer from being &quot;obtuse and unintuitive&quot;. I don&#039;t know if they should considered a &quot;test suite&quot;, though.

S</description>
		<content:encoded><![CDATA[<p>PHP&#8217;s .phpt (php tests) are extremely simple, and don&#8217;t suffer from being &#8220;obtuse and unintuitive&#8221;. I don&#8217;t know if they should considered a &#8220;test suite&#8221;, though.</p>
<p>S</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul M. Jones</title>
		<link>http://paul-m-jones.com/archives/82/comment-page-1#comment-744</link>
		<dc:creator>Paul M. Jones</dc:creator>
		<pubDate>Thu, 09 Dec 2004 18:43:35 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=82#comment-744</guid>
		<description>Hi, Travis --

I can&#039;t say I know much about automated testing to begin with, so my opinion here is likely uninformed.  However, I have yet to see a testing suite that lends itself to easy understanding of the underlying code; that is, the automated test itself is obtuse and unintuitive.  As you point out, framework of the test itself hampers the new user&#039;s analysis of (a) what the test is doing, (b) why, and (c) how that applies to the use of the package.

Not saying that automated testing is bad (far from it! it is good!) only that the automated tests I have seen would not be good code examples or code tutorials for the package they test.</description>
		<content:encoded><![CDATA[<p>Hi, Travis &#8211;</p>
<p>I can&#8217;t say I know much about automated testing to begin with, so my opinion here is likely uninformed.  However, I have yet to see a testing suite that lends itself to easy understanding of the underlying code; that is, the automated test itself is obtuse and unintuitive.  As you point out, framework of the test itself hampers the new user&#8217;s analysis of (a) what the test is doing, (b) why, and (c) how that applies to the use of the package.</p>
<p>Not saying that automated testing is bad (far from it! it is good!) only that the automated tests I have seen would not be good code examples or code tutorials for the package they test.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Travis Swicegood</title>
		<link>http://paul-m-jones.com/archives/82/comment-page-1#comment-743</link>
		<dc:creator>Travis Swicegood</dc:creator>
		<pubDate>Thu, 09 Dec 2004 18:25:39 +0000</pubDate>
		<guid isPermaLink="false">http://paul-m-jones.com/blog/?p=82#comment-743</guid>
		<description>I&#039;d have to say I sort of disagree with you here - only &quot;sort of&quot; because I think a properly commented automated test could serve the same purpose.  I try to make it a habit to include a final test case that duplicates all of the individual tests but in a &quot;real world&quot; scenario.  For Savant, that might be a full initialization of Savant, loading a template, checking for a few of the correct patterns followed by the same for plug-ins, filters, and finally both together.  Basically, it would be what you have right now with the exception that you&#039;re relying on the computer to &quot;eyeball&quot; the results.

Of course, its usefulness might be mitigated by the fact that it would be buried in the framework of the automated tests, but if you have the proper pointers to it folks could find it.</description>
		<content:encoded><![CDATA[<p>I&#8217;d have to say I sort of disagree with you here &#8211; only &#8220;sort of&#8221; because I think a properly commented automated test could serve the same purpose.  I try to make it a habit to include a final test case that duplicates all of the individual tests but in a &#8220;real world&#8221; scenario.  For Savant, that might be a full initialization of Savant, loading a template, checking for a few of the correct patterns followed by the same for plug-ins, filters, and finally both together.  Basically, it would be what you have right now with the exception that you&#8217;re relying on the computer to &#8220;eyeball&#8221; the results.</p>
<p>Of course, its usefulness might be mitigated by the fact that it would be buried in the framework of the automated tests, but if you have the proper pointers to it folks could find it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

