<?xml version="1.0" encoding="UTF-8"?><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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Google Data &#187; Christopher Semturs</title>
	<atom:link href="/author/christopher-semturs/feed/" rel="self" type="application/rss+xml" />
	<link>https://googledata.org</link>
	<description>Everything Google: News, Products, Services, Content, Culture</description>
	<lastBuildDate>Fri, 03 Apr 2015 21:58:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>Do Know Evil</title>
		<link>https://googledata.org/google-testing/do-know-evil/</link>
		<comments>https://googledata.org/google-testing/do-know-evil/#comments</comments>
		<pubDate>Thu, 06 May 2010 10:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Christopher Semturs]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Web Application Exploits and Defenses  by Bruce Leban in Google Kirkland  http://google-gruyere.appspot.com/  If you want your application to be as secure as possible, you need to learn how Evil People think. And you'll want to use that knowledge to do...]]></description>
				<content:encoded><![CDATA[<div style="text-align: center;"><span class="Apple-style-span"   style="  ;font-family:Arial, sans-serif;font-size:x-large;"><b><span style="background: none repeat scroll 0% 0% transparent;">Web Application Exploits and Defenses</span></b></span></div> <p class="western" style="margin-top: 0.25cm; margin-bottom: 0cm; font-weight: normal;" align="CENTER" lang="en-US"> <span style="color: rgb(0, 0, 0);"><span style="font-size:100%;"><i><span style="background: none repeat scroll 0% 0% transparent;">by Bruce Leban in Google Kirkland</span></i></span></span></p> <p class="western" style="margin-top: 0.25cm; margin-bottom: 0.25cm; background: none repeat scroll 0% 0% transparent;" align="CENTER"> <span style="font-size:100%;"><span style="color: rgb(0, 0, 128);"><span style="color: rgb(0, 0, 255);"><span style="font-family:Courier New,monospace;"><span style="font-size:180%;"><span lang="en-US"><span style="text-decoration: none;"><b>http://google-gruyere.appspot.com/</b></span></span></span></span></span></span></span></p> <p class="western" style="margin-bottom: 0cm; background: none repeat scroll 0% 0% transparent;" align="LEFT"> <span style="font-size:100%;"><span style="color: rgb(0, 0, 0);"><span style="font-family:Times New Roman,serif;"><span lang="en-US"><span style="font-weight: normal;">If you want your application to be as secure as possible, you need to </span></span></span></span><span style="color: rgb(128, 0, 0);"><span style="font-family:Times New Roman,serif;"><span lang="en-US"><b>learn how Evil People think.</b></span></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><span style="font-weight: normal;"> </span></span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US">And you'll want to use that knowledge to</span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US"><b> </b></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><b>do penetration testing:</b></span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US"> attacking your own application to try to find bugs.</span></span></span></p> <p class="western" style="margin-top: 0.25cm; margin-bottom: 0cm; background: none repeat scroll 0% 0% transparent;" align="LEFT"> <span style="font-size:100%;"><span style="color: rgb(0, 0, 0);"><span lang="en-US"><span style="font-weight: normal;">To help you </span></span></span><span style="color: rgb(128, 0, 0);"><span style="font-family:Times New Roman,serif;"><span lang="en-US"><b>understand ho</b></span></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><b>w applications can be attacked </b></span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US">and how to protect them from attack, </span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US"><span style="font-weight: normal;">we've created the </span></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><b>“Web Application Exploits and Defenses” codelab</b></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><span style="font-weight: normal;">. </span></span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US"><span style="font-weight: normal;">Th</span></span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US">e codelab uses </span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US"><span style="font-weight: normal;">Gruyere</span></span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US">, a small, cheesy, web application that is full of real world bugs. </span></span></span> </p> <p class="western" style="margin-top: 0.25cm; margin-bottom: 0cm; font-weight: normal;" lang="en-US"> <span style="color: rgb(0, 0, 0);"><span style="font-size:100%;">In the codelab, you'll learn how to:</span></span></p> <ul><li><p class="western" style="margin-top: 0.25cm; margin-bottom: 0cm;">  <span style="font-size:100%;"><span style="color: rgb(0, 0, 0);"><span lang="en-US"><span style="font-weight: normal;">Attack  a web application</span></span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US">  to find and exploit common web security vulnerabilities.</span></span></span></p>  </li><li><p class="western" style="margin-top: 0.25cm; margin-bottom: 0cm; font-weight: normal;" lang="en-US">  <span style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Avoid and  fix these common bugs.</span></span></p> </li></ul> <p class="western" style="margin-top: 0.25cm; margin-bottom: 0.2cm; background: none repeat scroll 0% 0% transparent;" align="LEFT"> <span style="font-size:100%;"><span style="color: rgb(0, 0, 0);"><span lang="en-US">Gruyere is chock full of cool features, and </span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><b>the more features</b></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"> </span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US">an application has </span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><b>th</b></span></span><span style="color: rgb(128, 0, 0);"><span style="font-family:Times New Roman,serif;"><span lang="en-US"><b>e larger the attac</b></span></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><b>k surface.</b></span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US"> </span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US"><span style="font-weight: normal;">Your application probably has features just like these:</span></span></span></span></p> <p class="western" style="margin-top: 0.11cm; margin-bottom: 0.11cm;" align="LEFT" lang="en-US"> <span style="color: rgb(0, 0, 0);"><span style="font-size:100%;"><b>Can you match each feature to the vulnerability that it exposes and the exploit it enables?</b></span></span></p><p class="western" style="margin-top: 0.11cm; margin-bottom: 0.11cm;" align="LEFT" lang="en-US"></p><dl><dd><br /><br /><table style="color: rgb(0, 0, 0);" width="100%" border="1" cellpadding="8" cellspacing="0">   <col width="256*">   <tbody><tr>    <td bg="" style="color: rgb(255, 255, 204);" width="100%">     <p class="western" style="margin-top: 0.11cm;" lang="en-US"><span style="color: rgb(0, 0, 0);"><span style="font-size:100%;"><b>Feature</b></span></span></p>    </td>   </tr>   <tr>    <td bg="" style="color: rgb(255, 255, 204);" width="100%">     <p class="western" style="margin-top: 0.11cm;" lang="en-US"><span style="color: rgb(0, 0, 0);"><span style="font-size:100%;">New     template language<br />HTML allowed in snippets<br />File upload     capability<br />AJAX<br />Web-based admin console</span></span></p>    </td>   </tr>  </tbody></table> </dd></dl> <p class="western" style="margin-top: 0.11cm; margin-bottom: 0.11cm;" align="CENTER" lang="en-US"><br /></p> <dl><dd>  <table style="color: rgb(0, 0, 0);" width="100%" border="1" cellpadding="8" cellspacing="0">   <col width="256*">   <tbody><tr>    <td bg="" style="color: rgb(255, 255, 204);" width="100%">     <p class="western" style="margin-top: 0.11cm;" lang="en-US"><span style="color: rgb(0, 0, 0);"><span style="font-size:100%;"><b>Vulnerability</b></span></span></p>    </td>   </tr>   <tr>    <td bg="" style="color: rgb(255, 255, 204);" width="100%">     <p class="western" style="margin-top: 0.11cm;" lang="en-US"><span style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Cross     Site Scripting (XSS)<br />Cross Site Request Forgery (XSRF)<br />Cross     Site Script Inclusion (XSSI)<br />Path traversal<br />Client-state     manipulation</span></span></p>    </td>   </tr>  </tbody></table> </dd></dl> <p class="western" style="margin-top: 0.11cm; margin-bottom: 0.11cm;" align="CENTER" lang="en-US"><br /></p> <dl><dd>  <table style="color: rgb(0, 0, 0);" width="100%" border="1" cellpadding="8" cellspacing="0">   <col width="256*">   <tbody><tr>    <td bg="" style="color: rgb(255, 255, 204);" width="100%">     <p class="western" style="margin-top: 0.11cm;" lang="en-US"><span style="color: rgb(0, 0, 0);"><span style="font-size:100%;"><b>Exploit</b></span></span></p>    </td>   </tr>   <tr>    <td bg="" style="color: rgb(255, 255, 204);" width="100%">     <p class="western" style="margin-top: 0.11cm;" lang="en-US"><span style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Information     disclosure<br />Elevation of privilege<br />Denial of Service     (DoS)<br />Spoofing<br />Code execution</span></span></p>    </td>   </tr>  </tbody></table> </dd></dl> <p class="western" style="margin-top: 0.11cm; margin-bottom: 0.11cm;" align="LEFT" lang="en-US"> <span style="font-size:100%;"><span style="color: rgb(0, 0, 0);">Ha! Tricked you! Each of these features introduces multiple vulnerabilities. And each vulnerability can be exploited in multiple ways.</span><span style="color: rgb(153, 51, 0);"><b> </b></span><span style="color: rgb(128, 0, 0);"><b>The codelab walks you step by step through each vulnerability</b></span><span style="color: rgb(128, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"> with progressive hints guiding you on how to find them, how to exploit them and how to avoid them.</span></span></p> <p class="western" style="margin-top: 0.25cm; margin-bottom: 0.2cm;"><span style="font-size:100%;"><span style="color: rgb(0, 0, 0);"><span lang="en-US">Here are </span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US"><span style="font-weight: normal;">some </span></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><b>examples of </b></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><i><b>fictitious </b></i></span></span><span style="color: rgb(128, 0, 0);"><span lang="en-US"><b>attacks</b></span></span><span style="color: rgb(153, 51, 0);"><span lang="en-US"><b> </b></span></span><span style="color: rgb(0, 0, 0);"><span lang="en-US">against Google applications. Do you recognize them? (answers below)</span></span></span></p> <dl><dd>  <table style="color: rgb(0, 0, 0);" width="782" border="1" cellpadding="8" cellspacing="0">   <col width="764">   <tbody><tr>    <td bg="" style="color: rgb(230, 255, 230);" width="764">     <p class="western" style="margin-top: 0.11cm;"><span style="font-size:100%;"><span style="font-family:Courier New,monospace;"><span style="white-space:nowrap;font-size:85%;"><span style="color: rgb(0, 0, 0);"><span style="font-size:85%;"><span lang="en-US">http://www.gmail.com/?search=in:spam+%3Cscript%3EmoveToInbox(selectAll())%3C/script%3E<br />http://www.blogger.com/delete-blog.g<br />http://www.picasa.com/../../../../../../../etc/passwd<br />http://www.youtube.com/admin?v=Vr0oK3gMzK&amp;action=rickroll<br />http://checkout.google.com/buy?order=4815162342&amp;total=0.01</span></span></span></span></span></span></p>    </td>   </tr>  </tbody></table> </dd></dl> <p class="western" style="margin-top: 0.25cm; margin-bottom: 0.2cm; background: none repeat scroll 0% 0% transparent;" align="LEFT"> <span style="font-size:100%;"><span style="color: rgb(128, 0, 0);"><span style="font-family:Times New Roman,serif;"><span lang="en-US"><b>Are you sure that your application isn't vulnerable to similar attacks!?</b></span></span></span></span><br /></p><p>Check out the <a href="http://code.google.com/intl/de-CH/testing/TotT-2010-04-08.pdf">Toilet-Friendly Version for the answers</a><br /></p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15045980-8212305300544840757?l=googletesting.blogspot.com' alt='' /></div>]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/do-know-evil/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TotT: Making a Perfect Matcher</title>
		<link>https://googledata.org/google-testing/tott-making-a-perfect-matcher/</link>
		<comments>https://googledata.org/google-testing/tott-making-a-perfect-matcher/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 08:45:00 +0000</pubDate>
		<dc:creator><![CDATA[Christopher Semturs]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[by Zhanyong G. Mock Wan in Google KirklandIn the previous episode, we showed how Google C++ Mocking Framework matchers can make both your test code and your test output readable. What if you cannot find the right matcher for the task't settle for a...]]></description>
				<content:encoded><![CDATA[<span style="font-size:78%;">by Zhanyong G. Mock Wan in Google Kirkland<br /></span><br />In the previous episode, we showed how <strong><span style="color:#990000;">Google C++ Mocking Framework matchers can make both your test code and your test output readable</span></strong>. What if you cannot find the right matcher for the task?<br /><br />Don't settle for anything less than perfect. <span style="color:#990000;"><strong>It's easy to create a matcher that does exactly what you want, either by composing from existing matchers or by writing one from scratch</strong></span>.<br /><br />The simplest <em>composite matcher</em> is <strong>Not(m)</strong>, which negates matcher <em>m</em> as you may have guessed. We also have <strong>AnyOf(m1, ..., mn)</strong> for <strong>OR</strong>-ing and <strong>AllOf(m1, ..., mn)</strong> for <strong>AND</strong>-ing. Combining them wisely and you can get a lot done. For example,<br /><br /><p style="BORDER-BOTTOM: rgb(128,128,128) 1px solid; BORDER-LEFT: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,245,255); MARGIN-LEFT: 0.39in; BORDER-TOP: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-RIGHT: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="font-family:courier new;">EXPECT_THAT(new_code, <b>AnyOf</b>(StartsWith(“// Tests”)),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Not</b>(ContainsRegex(“TODO.*intern”))));<br /></span></p>could generate a message like:<br /><br /><p style="BORDER-BOTTOM: rgb(128,128,128) 1px solid; BORDER-LEFT: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,245,255); MARGIN-LEFT: 0.39in; BORDER-TOP: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-RIGHT: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="font-family:courier new;"><b>Expected:</b> (starts with “// Tests”) or<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(doesn't contain regular expression “TODO.*intern”)<br /><b>Actual:</b> “/* TODO: hire an intern. */ int main() {}”<br /></span></p>If the matcher expression gets too complex, or your matcher logic cannot be expressed in terms of existing matchers, you can use plain C++. <span style="color:#990000;"><strong>The MATCHER macro lets you define a named matcher</strong></span>:<br /><br /><p style="BORDER-BOTTOM: rgb(128,128,128) 1px solid; BORDER-LEFT: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,245,255); MARGIN-LEFT: 0.39in; BORDER-TOP: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-RIGHT: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="font-family:courier new;"><b>MATCHER</b>(<b>IsEven</b>, “”) { return (<b>arg</b> % 2) == 0; }<br /></span></p>allows you to write <strong>EXPECT_THAT(paren_num, IsEven())</strong> to verify that paren_num is divisible by two. The special variable arg refers to the value being validated (paren_num in this case) – it is <em>not</em> a global variable.<br /><br />You can put <em>any code</em> between {} to validate arg, as long as it returns a bool value.<br /><br />The empty string “” tells Google C++ Mocking Framework to <em>automatically generate</em> the matcher's description from its name (therefore you'll see “<span style="font-family:courier new;">Expected: is even</span>” when the match fails). As long as you pick a descriptive name, you get a good description for free.<br /><br /><span style="color:#990000;"><strong>You can also give multiple parameters to a matcher, or customize its description</strong></span>. The code:<br /><p style="BORDER-BOTTOM: rgb(128,128,128) 1px solid; BORDER-LEFT: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,245,255); MARGIN-LEFT: 0.39in; BORDER-TOP: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-RIGHT: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="font-family:courier new;">// P2 means the matcher has 2 parameters. Their names are low and high.<br /><br /><b>MATCHER_P2</b>(<b>InClosedRange</b>, <b>low</b>, <b>high</b>, “is in range [<b>%(low)s</b>, <b>%(high)s</b>]”) {<br />&nbsp;&nbsp;return low <= arg &amp;&amp; arg <= high;<br />}<br />...<br />EXPECT_THAT(my_age, <b>InClosedRange</b>(adult_min, penalty_to_withdraw_401k)); </span></p>may print:<br /><br /><p style="BORDER-BOTTOM: rgb(128,128,128) 1px solid; BORDER-LEFT: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,245,255); MARGIN-LEFT: 0.39in; BORDER-TOP: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-RIGHT: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="font-family:courier new;"><b>Expected:</b> is in range [18, 60]<br />&nbsp;&nbsp;<b>Actual:</b> 2</span><br /></p>(No, that's not my real age.) Note how you can use Python-style interpolation in the description string to print the matcher parameters.<br />You may wonder why we haven't seen any types in the examples. Rest assured that all the code we showed you is type-safe. <strong><span style="color:#990000;">Google C++ Mocking Framework uses compiler type inference to “write” the matcher parameter types for you</span></strong>, so that you can spend the time on actually writing tests – or finding your perfect match.<br /><br /><a href="http://code.google.com/intl/de-CH/testing/TotT-2009-10-05.pdf">Toilet-Friendly Version</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15045980-1204733198786401529?l=googletesting.blogspot.com' alt='' /></div>]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/tott-making-a-perfect-matcher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TotT: Literate Testing With Matchers</title>
		<link>https://googledata.org/google-testing/tott-literate-testing-with-matchers/</link>
		<comments>https://googledata.org/google-testing/tott-literate-testing-with-matchers/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 17:57:00 +0000</pubDate>
		<dc:creator><![CDATA[Christopher Semturs]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[By Zhanyong G. Mock Wan in Google KirklandAlright, it sounds like a good idea to verify that matchmakers can read and write. How does this concern us programmers, though?Actually, we are talking about a way of writing tests here – a way that makes bo...]]></description>
				<content:encoded><![CDATA[<em><span style="font-size:85%;">By Zhanyong G. Mock Wan in Google Kirkland</span></em><br /><br />Alright, it sounds like a good idea to verify that matchmakers can read and write. How does this concern us programmers, though?<br />Actually, we are talking about a way of writing tests here – a way that makes both the test code and its output read like English (hence “literate”). The key to this technique is <strong><span style="color:#cc0000;">matchers</span></strong>, which <strong><span style="color:#cc0000;">are predicates that know how to describe themselves</span></strong>. For example, in Google C++ Mocking Framework, <strong>ContainsRegex</strong>(<span style="font-family:courier new;">"Ahcho+!"</span>) is a matcher that matches any string that has the regular expression <span style="font-family:courier new;">"Ahcho+!"</span> in it. Therefore, it matches <span style="font-family:courier new;">"Ahchoo!"</span> and <span style="font-family:courier new;">"Ahchoooo! Sorry."</span>, but not <span style="font-family:courier new;">"Aha!"</span>.<br />What's this to do with test readability, anyway? It turns out that <strong><span style="color:#cc0000;">matchers</span></strong>, whose names are usually verb phrases, <strong><span style="color:#cc0000;">lend themselves easily to an assertion style that resembles natural languages</span></strong>. Namely, the assertion<br /><br /><p style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,245,255); MARGIN-LEFT: 0.39in; BORDER-LEFT: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-BOTTOM: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="font-family:courier new;color:#000000;"><strong>EXPECT_THAT</strong>(value, matcher);</span></p><br />succeeds if <i>value</i> matches <i>matcher</i>. For example,<br /><p style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,245,255); MARGIN-LEFT: 0.39in; BORDER-LEFT: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-BOTTOM: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="color:#000000;">#include &lt;gmock/gmock.h&gt;<br />using ::testing::Contains;<br />...<br />EXPECT_THAT(GetUserList(), Contains(admin_id));</span></p><br />verifies that the result of <span style="font-family:courier new;">GetUserList()</span> contains the administrator.<br /><br />Now, pretend the punctuations aren't there in the last C++ statement and read it. See what I mean?<br /><br />Better yet, <strong><span style="color:#cc0000;">when an EXPECT_THAT assertion fails, it will print an informative message that includes the expression being validated, its value, and the property we expect it to have</span></strong> – thanks to a matcher's ability to describe itself in human-friendly language. Therefore, not only is the test code readable, the test output it generates is readable too. For instance, the above example might produce:<br /><p style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; BACKGROUND: rgb(255,255,50); MARGIN-LEFT: 0.39in; BORDER-LEFT: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-BOTTOM: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="font-family:courier new;color:#660000;"><strong>Value of:</strong> GetUserList()<br /><strong>Expected:</strong> contains "yoko"<br /><strong>&nbsp;&nbsp;Actual:</strong> { "john", "paul", "george", "ringo" }</span></p><br />This message contains relevant information for diagnosing the problem, often without having to use a debugger.<br />To get the same effect without using a matcher, you'd have to write something like:<br /><p style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,245,255); MARGIN-LEFT: 0.39in; BORDER-LEFT: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-BOTTOM: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="color:#000000;">std::vector&lt;std::string&gt; users = GetUserList();<br />EXPECT_TRUE(VectorContains(users, admin_id))<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt; " GetUserList() returns " &lt;&lt; users<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt; " and admin_id is " &lt;&lt; admin_id;</span><br /></p><br />which is harder to write and less clear than the one-liner we saw earlier.<br /><br />Google C++ Mocking Framework (<a href="http://code.google.com/p/googlemock/">http://code.google.com/p/googlemock/</a>) provides dozens of matchers for validating many kinds of values: numbers, strings, STL containers, structs, etc. They all produce friendly and informative messages. See <a href="http://code.google.com/p/googlemock/wiki/CheatSheet">http://code.google.com/p/googlemock/wiki/CheatSheet</a> to learn more. If you cannot<br />find one that matches (pun intended) your need, you can either combine existing matchers, or define your own from scratch. Both are quite easy to do. We'll show you how in another episode. Stay tuned!<br /><br /><a href="http://code.google.com/intl/de-CH/testing/TotT-2009-09-28.pdf">Toilet-friendly version</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15045980-8559119593676951275?l=googletesting.blogspot.com' alt='' /></div>]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/tott-literate-testing-with-matchers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TotT: Testing GWT without GwtTestCase</title>
		<link>https://googledata.org/google-testing/tott-testing-gwt-without-gwttestcase/</link>
		<comments>https://googledata.org/google-testing/tott-testing-gwt-without-gwttestcase/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 07:53:00 +0000</pubDate>
		<dc:creator><![CDATA[Christopher Semturs]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Because GWT (Google Web Toolkit) is new and exciting it's easy to forget the lessons on clean GUI code structure that have been accumulated over nearly thirty years.GwtTestCase is good for testing UI-specific code in JavaScript. If you find yourself us...]]></description>
				<content:encoded><![CDATA[<div id="doc-contents"><p class="western"  style="font-family:Times New Roman;">Because GWT (Google Web Toolkit) is new and exciting it's easy to forget the lessons on clean GUI code structure that have been accumulated over nearly thirty years.</p><p class="western" style="TEXT-ALIGN: left" face="Times New Roman">GwtTestCase is good for testing UI-specific code in JavaScript. If you find yourself using GwtTestCase for testing non-ui client-side logic you may not have a clear View/Presenter separation. <b>Separating the View and the Presenter allows for more modular, more easily tested code with shorter test times</b>. Model View Presenter was introduced in another <span style="FONT-STYLE: normal"><a id="llx6" title="episode back in February" href="http://googletesting.blogspot.com/2009/02/with-all-sport-drug-scandals-of-late.html">episode back in February</a>. </span><b>Here's how to apply it to a GWT app.</b><br /></p><p class="western" style="TEXT-ALIGN: left" face="Times New Roman"><b>Defining terms:</b><br /></p><div style="MARGIN-LEFT: 40px;font-family:Times New Roman;" ><ul><li><b style="COLOR: rgb(153,0,0)">Server</b><span style="COLOR: rgb(0,0,0)"> – a completely standard backend with <span style="FONT-STYLE: normal"><b>no dependency on GWT</b>.</span></span></li></ul></div><div style="MARGIN-LEFT: 40px; FONT-FAMILY: Times New Roman"><ul><li><b><span style="COLOR: rgb(153,0,0)">Model</span> </b><span style="COLOR: rgb(0,0,0)">– the data model. May be shared between the client and server side, or if appropriate you might have a different model for the client side. It has <b>no dependency on GWT</b>.</span></li></ul></div><div style="MARGIN-LEFT: 40px" face="Times New Roman"><ul><li><b><span style="COLOR: rgb(128,0,0)"><span style="COLOR: rgb(153,0,0)">View</span> </span></b><span style="FONT-STYLE: normal"><span style="COLOR: rgb(0,0,0)">– the display. <b>Classes in the view wrap GWT widgets</b>, hiding them from the rest of your code. They contain <b>no logic</b>, <b>no state</b>, and are <b>easy to mock</b>.</span></span></li></ul><ul><li><b><span style="COLOR: rgb(128,0,0)"><span style="COLOR: rgb(153,0,0)">Presenter</span> </span></b><span style="FONT-STYLE: normal"><span style="COLOR: rgb(0,0,0)">– all the client side logic and state; it talks to the server and tells the view what to do. It <b>uses RPC mechanisms from GWT </b>but<b> no widgets</b>.</span></span></li></ul></div><p class="western" align="left" face="Times New Roman"><b>The Presenter, which contains all the interesting client-side code is fully testable in Java!</b></p><p style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,245,255); MARGIN-LEFT: 0.39in; BORDER-LEFT: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-BOTTOM: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="font-family:Courier New, monospace;">public void testRefreshPersonListButtonWasClicked() {<br />IMocksControl easyMockContext = EasyMock.createControl()<br />mockServer = easyMockContext.createMock(Server.class);<br />mockView = easyMockContext.createMock(View.class);<span style="font-family:Courier New, monospace;"><br />List<person> franz = Lists.newArrayList(new Person("Franz", "Mayer"));<b><br />mockServer.getPersonList(AsyncCallbackSuccessMatcher&lt;list&lt;person>>reportSuccess(franz)));<br />mockView.clearPersonList());<br />mockView.addPerson(“Franz”, “Mayer”);</b></span><br />easyMockContext.replay();<br />presenter.refreshPersonListButtonClicked();<br />easyMockContext.verify();<br />}</span></p><p class="western" align="left" face="Times New Roman"><b>Testing failure cases is now as easy as changing expectations.</b> By swapping in the following expectations, the above test goes from testing success to testing that after two server failures, we show an error message.</p><p style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; BACKGROUND: rgb(230,255,230); MARGIN-LEFT: 0.39in; BORDER-LEFT: rgb(128,128,128) 1px solid; MARGIN-RIGHT: 0.39in; BORDER-BOTTOM: rgb(128,128,128) 1px solid; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous"><span style="font-family:Courier New, monospace;">mockServer.getPersonList(AsyncCallbackFailureMatcher&lt;list&lt;person>><b>reportFailure</b>(failedExpn))<br />expectLastCall().times(2); <i>// Ensure the presenter tries twice<br /></i><br />mockView.showErrorMessage(“Sorry, please try again later”));</span></p><p class="western" style="FONT-FAMILY: Times New Roman"><span style="color:#000000;">You'll still need an end-to-end test. But <b>all your <span style="FONT-STYLE: normal">logic</span> <span style="FONT-STYLE: normal">can be tested in small and fast tests.</span></b> </span></p><p class="western" style="FONT-STYLE: normal" face="Times New Roman">The Source Code for the Matchers is open-sourced and can be downloaded here: <a id="po8i" title="AsynCallbackSuccessMatcher.java" href="http://code.google.com/p/gwt-callback-matchers-for-easymock/source/browse/trunk/src/AsyncCallbackSuccessMatcher.java">AsyncCallbackSuccessMatcher.java</a> - <a id="yaum" title="AsyncCallbackFailureMatcher.java" href="http://code.google.com/p/gwt-callback-matchers-for-easymock/source/browse/trunk/src/AsyncCallbackFailureMatcher.java">AsyncCallbackFailureMatcher.java</a>.</p><p class="western" style="FONT-STYLE: normal" face="Times New Roman">Consider using Test Driven Development (TDD) to develop the presenter. It tends to result in higher test coverage, faster and more relevant tests, as well as a better code structure.</p><p class="western" face="Times New Roman"><br /></p><p class="western" face="Times New Roman"><i><span style="font-family:Times New Roman;">This week's episode by David Morgan, Christopher Semturs and Nicolas Wettstein based in Zürich, Switzerland – having a real Mountain View</span></i><a id="rmpv" title="Toilet-friendly version" href="http://code.google.com/intl/de-CH/testing/TotT-2009-08-07.pdf"><br /><br /></a></p><p class="western" face="Times New Roman"><a id="ksh_" title="Toilet-friendly version" href="http://code.google.com/intl/de-CH/testing/TotT-2009-08-07.pdf">Toilet-friendly version</a><br /></p><p class="western" face="Times New Roman"><a id="by8d" title="AsynCallbackSuccessMatcher.java" style="COLOR: rgb(85,26,139)" href="http://code.google.com/p/gwt-callback-matchers-for-easymock/source/browse/trunk/src/AsyncCallbackSuccessMatcher.java">AsyncCallbackSuccessMatcher.java</a></p><p class="western" style="FONT-FAMILY: Times New Roman"><a id="he0i" title="AsyncCallbackFailureMatcher.java" style="COLOR: rgb(85,26,139)" href="http://code.google.com/p/gwt-callback-matchers-for-easymock/source/browse/trunk/src/AsyncCallbackFailureMatcher.java">AsyncCallbackFailureMatcher.java</a>.<br /></p></div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/15045980-1479275730986763877?l=googletesting.blogspot.com' alt='' /></div>]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/tott-testing-gwt-without-gwttestcase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
