<?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: Test behaviour not syntax	</title>
	<atom:link href="http://matteo.vaccari.name/blog/archives/407/feed" rel="self" type="application/rss+xml" />
	<link>http://matteo.vaccari.name/blog/archives/407</link>
	<description>Extreme enthusiasm</description>
	<lastBuildDate>
	Mon, 25 Feb 2019 15:18:16 +0000	</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.1.1</generator>
			<item>
				<title>
				By: matteo				</title>
				<link>http://matteo.vaccari.name/blog/archives/407/comment-page-1#comment-93308</link>
		<dc:creator><![CDATA[matteo]]></dc:creator>
		<pubDate>Tue, 22 Jun 2010 13:50:05 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=407#comment-93308</guid>
					<description><![CDATA[Hi Franco,

thanks for your criticism!!  Yes, I see how that could be a problem.  The prolog problem I would fix by having the parser use an XML parser, so that invalid xml would cause an exception.  But I could get that also by testing the XML against XPath queries, as Jacopo suggests in the next post.

YMMV, but I still think it&#039;s valuable to write code to extract the information from the xml and check this information.  The extraction code could be a separate class, or private testing methods inside the test class.  

I see how it would be valuable to *also* have a check that the syntax conforms to what I expect.  But that would be a *testing* test, not a TDD test.  I think that tests with serialize-then-parse would be better for driving the design.]]></description>
		<content:encoded><![CDATA[<p>Hi Franco,</p>
<p>thanks for your criticism!!  Yes, I see how that could be a problem.  The prolog problem I would fix by having the parser use an XML parser, so that invalid xml would cause an exception.  But I could get that also by testing the XML against XPath queries, as Jacopo suggests in the next post.</p>
<p>YMMV, but I still think it&#8217;s valuable to write code to extract the information from the xml and check this information.  The extraction code could be a separate class, or private testing methods inside the test class.  </p>
<p>I see how it would be valuable to *also* have a check that the syntax conforms to what I expect.  But that would be a *testing* test, not a TDD test.  I think that tests with serialize-then-parse would be better for driving the design.</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: Franco Lombardo				</title>
				<link>http://matteo.vaccari.name/blog/archives/407/comment-page-1#comment-93305</link>
		<dc:creator><![CDATA[Franco Lombardo]]></dc:creator>
		<pubDate>Tue, 22 Jun 2010 06:06:35 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=407#comment-93305</guid>
					<description><![CDATA[Matteo,

this time I partially disagree with your point. Well, if it&#039;s obviously a bad practice to test the raw XML string since, as you pointed out, it would create a really brittle test, I don&#039;t feel comfortable with your solution.
First of all, I entirely agree with Jacopo&#039;s annotations. But what I would underline here is that you wrote what I call an &quot;ever green test&quot;. I mean that your test could be successful even when both XmlSerializer and XmlParser are wrong, if the mistakes in the two classes are symmetric. Think, for example, to the case of the broken XML prolog you showed: if both classes use a broken prolog, they will talk each other, but they will never talk to anyone else. Or you can think of both classes serializing and de-serializing decimal numbers using comma as a decimal separator, as in the Italian convention (I really did this mistake, so I&#039;m pretty an expert ;-) ). 
You said that in your use case the two classes need to talk to each other and not to the rest of the world, so my annotations could be of no interest, anyway I think we need to take care of &quot;ever green tests&quot;.]]></description>
		<content:encoded><![CDATA[<p>Matteo,</p>
<p>this time I partially disagree with your point. Well, if it&#8217;s obviously a bad practice to test the raw XML string since, as you pointed out, it would create a really brittle test, I don&#8217;t feel comfortable with your solution.<br />
First of all, I entirely agree with Jacopo&#8217;s annotations. But what I would underline here is that you wrote what I call an &#8220;ever green test&#8221;. I mean that your test could be successful even when both XmlSerializer and XmlParser are wrong, if the mistakes in the two classes are symmetric. Think, for example, to the case of the broken XML prolog you showed: if both classes use a broken prolog, they will talk each other, but they will never talk to anyone else. Or you can think of both classes serializing and de-serializing decimal numbers using comma as a decimal separator, as in the Italian convention (I really did this mistake, so I&#8217;m pretty an expert ;-) ).<br />
You said that in your use case the two classes need to talk to each other and not to the rest of the world, so my annotations could be of no interest, anyway I think we need to take care of &#8220;ever green tests&#8221;.</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: Extreme Enthusiasm &#187; Blog Archive &#187; Answering Jacopo&#8217;s comment				</title>
				<link>http://matteo.vaccari.name/blog/archives/407/comment-page-1#comment-93277</link>
		<dc:creator><![CDATA[Extreme Enthusiasm &#187; Blog Archive &#187; Answering Jacopo&#8217;s comment]]></dc:creator>
		<pubDate>Wed, 16 Jun 2010 06:37:41 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=407#comment-93277</guid>
					<description><![CDATA[[...] &#171; Test behaviour not syntax [...]]]></description>
		<content:encoded><![CDATA[<p>[&#8230;] &laquo; Test behaviour not syntax [&#8230;]</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: matteo				</title>
				<link>http://matteo.vaccari.name/blog/archives/407/comment-page-1#comment-93276</link>
		<dc:creator><![CDATA[matteo]]></dc:creator>
		<pubDate>Wed, 16 Jun 2010 06:34:55 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=407#comment-93276</guid>
					<description><![CDATA[Hi Jacopo,

My answer got so long that I made a new post about it :-)]]></description>
		<content:encoded><![CDATA[<p>Hi Jacopo,</p>
<p>My answer got so long that I made a new post about it :-)</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: jacopo				</title>
				<link>http://matteo.vaccari.name/blog/archives/407/comment-page-1#comment-93274</link>
		<dc:creator><![CDATA[jacopo]]></dc:creator>
		<pubDate>Tue, 15 Jun 2010 20:21:59 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=407#comment-93274</guid>
					<description><![CDATA[well, if you&#039;re lucky enough, both client and webservice will be under your control, so yes: focus on data (structure) sent/received, to be sure they&#039;re as expected.

but is far more common a scenario where webservice aren&#039;t under your control, they represent and integration point with external systems: that is, XML document syntax _is_ what you&#039;re trying to test. for example, (I can think of at least 2 cases that happened to me in the last 6 months) switching from one parsing library to another or simply testing interoperabily (such as Java/.NET).

of course, not as much domain logic there ;) but still, webservices aren&#039;t supposed to encapsulate domain knowledge, so focusing on syntax would be good enough.]]></description>
		<content:encoded><![CDATA[<p>well, if you&#8217;re lucky enough, both client and webservice will be under your control, so yes: focus on data (structure) sent/received, to be sure they&#8217;re as expected.</p>
<p>but is far more common a scenario where webservice aren&#8217;t under your control, they represent and integration point with external systems: that is, XML document syntax _is_ what you&#8217;re trying to test. for example, (I can think of at least 2 cases that happened to me in the last 6 months) switching from one parsing library to another or simply testing interoperabily (such as Java/.NET).</p>
<p>of course, not as much domain logic there ;) but still, webservices aren&#8217;t supposed to encapsulate domain knowledge, so focusing on syntax would be good enough.</p>
]]></content:encoded>
						</item>
			</channel>
</rss>
