<?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; Google Testing Bloggers</title>
	<atom:link href="/author/google-testing-bloggers/feed/" rel="self" type="application/rss+xml" />
	<link>https://googledata.org</link>
	<description>Everything Google: News, Products, Services, Content, Culture</description>
	<lastBuildDate>Thu, 19 Mar 2015 22:49:02 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.7.5</generator>
	<item>
		<title>The First Annual Testing on the Toilet Awards</title>
		<link>https://googledata.org/google-testing/the-first-annual-testing-on-the-toilet-awards/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-first-annual-testing-on-the-toilet-awards</link>
		<comments>https://googledata.org/google-testing/the-first-annual-testing-on-the-toilet-awards/#comments</comments>
		<pubDate>Tue, 03 Feb 2015 16:50:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=3cf7a52f667d3d964670861e791600ed</guid>
		<description><![CDATA[<i>By Andrew Trenk </i><br /><br />The Testing on the Toilet (TotT) series was <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">created</a> in 2006 as a way to spread unit-testing knowledge across Google by posting flyers in bathroom stalls. It quickly became a part of Google culture and is still going strong today, with new episodes published every week and read in hundreds of bathrooms by thousands of engineers in Google offices across the world. Initially focused on content related to testing, TotT now covers a variety of technical topics, such as tips on writing cleaner code and ways to prevent security bugs. <br /><br />While TotT episodes often have a big impact on many engineers across Google, until now we never did anything to formally thank authors for their contributions. To fix that, we decided to honor the most popular TotT episodes of 2014 by establishing the Testing on the Toilet Awards. The winners were chosen through a vote that was open to all Google engineers. The Google Testing Blog is proud to present the winners that were posted on this blog (there were two additional winners that weren&#8217;t posted on this blog since we only post testing-related TotT episodes). <br /><br />And the winners are ... <br /><br /><b>Erik Kuefler:</b> <a href="http://googletesting.blogspot.com/2014/04/testing-on-toilet-test-behaviors-not.html">Test Behaviors, Not Methods</a> and <a href="http://googletesting.blogspot.com/2014/07/testing-on-toilet-dont-put-logic-in.html">Don't Put Logic in Tests</a>&#160; <br /><b>Alex Eagle:</b> <a href="http://googletesting.blogspot.com/2015/01/testing-on-toilet-change-detector-tests.html">Change-Detector Tests Considered Harmful</a><br /><br />The authors of these episodes received their very own Flushy trophy, which they can proudly display on their desks. <br /><br /><div><a href="http://3.bp.blogspot.com/-AuTtNwV5Fp0/VND7kbIbybI/AAAAAAAAAH0/jvShp-Lgijw/s1600/image00.jpg"><img border="0" src="http://3.bp.blogspot.com/-AuTtNwV5Fp0/VND7kbIbybI/AAAAAAAAAH0/jvShp-Lgijw/s1600/image00.jpg" height="320" width="212"></a></div><br /><br />(The logo on the trophy is the same one we put on the printed version of each TotT episode, which you can see by looking for the &#8220;printer-friendly version&#8221; link in the <a href="http://googletesting.blogspot.com/search/label/TotT">TotT blog posts</a>). <br /><br />Congratulations to the winners! <br /><br />]]></description>
				<content:encoded><![CDATA[<i>By Andrew Trenk </i><br /><br />The Testing on the Toilet (TotT) series was <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">created</a> in 2006 as a way to spread unit-testing knowledge across Google by posting flyers in bathroom stalls. It quickly became a part of Google culture and is still going strong today, with new episodes published every week and read in hundreds of bathrooms by thousands of engineers in Google offices across the world. Initially focused on content related to testing, TotT now covers a variety of technical topics, such as tips on writing cleaner code and ways to prevent security bugs. <br /><br />While TotT episodes often have a big impact on many engineers across Google, until now we never did anything to formally thank authors for their contributions. To fix that, we decided to honor the most popular TotT episodes of 2014 by establishing the Testing on the Toilet Awards. The winners were chosen through a vote that was open to all Google engineers. The Google Testing Blog is proud to present the winners that were posted on this blog (there were two additional winners that weren’t posted on this blog since we only post testing-related TotT episodes). <br /><br />And the winners are ... <br /><br /><b>Erik Kuefler:</b> <a href="http://googletesting.blogspot.com/2014/04/testing-on-toilet-test-behaviors-not.html">Test Behaviors, Not Methods</a> and <a href="http://googletesting.blogspot.com/2014/07/testing-on-toilet-dont-put-logic-in.html">Don't Put Logic in Tests</a>&nbsp; <br /><b>Alex Eagle:</b> <a href="http://googletesting.blogspot.com/2015/01/testing-on-toilet-change-detector-tests.html">Change-Detector Tests Considered Harmful</a><br /><br />The authors of these episodes received their very own Flushy trophy, which they can proudly display on their desks. <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-AuTtNwV5Fp0/VND7kbIbybI/AAAAAAAAAH0/jvShp-Lgijw/s1600/image00.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-AuTtNwV5Fp0/VND7kbIbybI/AAAAAAAAAH0/jvShp-Lgijw/s1600/image00.jpg" height="320" width="212" /></a></div><br /><br />(The logo on the trophy is the same one we put on the printed version of each TotT episode, which you can see by looking for the “printer-friendly version” link in the <a href="http://googletesting.blogspot.com/search/label/TotT">TotT blog posts</a>). <br /><br />Congratulations to the winners! <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/the-first-annual-testing-on-the-toilet-awards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Change-Detector Tests Considered Harmful</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-change-detector-tests-considered-harmful/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-change-detector-tests-considered-harmful</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-change-detector-tests-considered-harmful/#comments</comments>
		<pubDate>Wed, 28 Jan 2015 00:42:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=9a94142ae086c345610f7f0f0dec7487</guid>
		<description><![CDATA[<i>by Alex Eagle <br /><br />This article was adapted from a  <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a  <a href="https://docs.google.com/document/d/13k8AsgYdF-2TJx9QIHHvPiuV3JMbsrMLkWmmjdYBLVg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br />You have just finished refactoring some code without modifying its behavior. Then you run the tests before committing and&#8230; a bunch of unit tests are failing. <span><b>While fixing the tests, you get a sense that you are wasting time by mechanically applying the same transformation to many tests.</b></span> Maybe you introduced a parameter in a method, and now must update 100 callers of that method in tests to pass an empty string. <br /><br /><span><b>What does it look like to write tests mechanically?</b></span> Here is an absurd but obvious way:<br /><pre><span>// Production code:</span><br />def abs(i: Int)<br /><span>return</span> (i &#60; 0) ? i * -1 : i<br /><br /><span>// Test code:</span><br /><span>for</span> (line: String in File(prod_source).read_lines())<br /><span>switch</span> (line.number)<br />    1: assert line.content equals def abs(i: Int)<br />    2: assert line.content equals   <span>return</span> (i &#60; 0) ? i * -1 : i</pre><br /><b><span>That test is clearly not useful</span></b>: it contains an exact copy of the code under test and acts like a checksum. <b><span>A correct or incorrect program is equally likely to pass</span></b> a test that is a derivative of the code under test. No one is really writing tests like that, but how different is it from this next example?<br /><pre><span>// Production code:</span><br />def process(w: Work)<br />  firstPart.process(w)<br />  secondPart.process(w)<br /><br /><span>// Test code:</span><br />part1 = mock(FirstPart)<br />part2 = mock(SecondPart)<br />w = Work()<br />Processor(part1, part2).process(w)<br />verify_in_order<br />  was_called part1.process(w)<br />  was_called part2.process(w)</pre><br />It is tempting to write a test like this because it requires little thought and will run quickly. <b><span>This is a change-detector test</span></b>&#8212;it is a transformation of the same information in the code under test&#8212;and <b><span>it breaks in response to any change to the production code, without verifying correct behavior</span></b> of either the original or modified production code. <br /><br /><b><span>Change detectors provide negative value</span></b>, since the tests do not catch any defects, and the added maintenance cost slows down development. These tests should be re-written or deleted. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Alex Eagle <br /><br />This article was adapted from a  <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a  <a href="https://docs.google.com/document/d/13k8AsgYdF-2TJx9QIHHvPiuV3JMbsrMLkWmmjdYBLVg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br />You have just finished refactoring some code without modifying its behavior. Then you run the tests before committing and… a bunch of unit tests are failing. <span style="color: purple;"><b>While fixing the tests, you get a sense that you are wasting time by mechanically applying the same transformation to many tests.</b></span> Maybe you introduced a parameter in a method, and now must update 100 callers of that method in tests to pass an empty string. <br /><br /><span style="color: purple;"><b>What does it look like to write tests mechanically?</b></span> Here is an absurd but obvious way:<br /><pre style="background: #cfe2f3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #4f8f00;">// Production code:</span><br />def abs(i: Int)<br />  <span style="color: #0433ff;">return</span> (i &lt; 0) ? i * -1 : i<br /><br /><span style="color: #4f8f00;">// Test code:</span><br /><span style="color: #0433ff;">for</span> (line: String in File(prod_source).read_lines())<br />  <span style="color: #0433ff;">switch</span> (line.number)<br />    1: assert line.content equals def abs(i: Int)<br />    2: assert line.content equals   <span style="color: #0433ff;">return</span> (i &lt; 0) ? i * -1 : i</pre><br /><b><span style="color: purple;">That test is clearly not useful</span></b>: it contains an exact copy of the code under test and acts like a checksum. <b><span style="color: purple;">A correct or incorrect program is equally likely to pass</span></b> a test that is a derivative of the code under test. No one is really writing tests like that, but how different is it from this next example?<br /><pre style="background: #cfe2f3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #4f8f00;">// Production code:</span><br />def process(w: Work)<br />  firstPart.process(w)<br />  secondPart.process(w)<br /><br /><span style="color: #4f8f00;">// Test code:</span><br />part1 = mock(FirstPart)<br />part2 = mock(SecondPart)<br />w = Work()<br />Processor(part1, part2).process(w)<br />verify_in_order<br />  was_called part1.process(w)<br />  was_called part2.process(w)</pre><br />It is tempting to write a test like this because it requires little thought and will run quickly. <b><span style="color: purple;">This is a change-detector test</span></b>—it is a transformation of the same information in the code under test—and <b><span style="color: purple;">it breaks in response to any change to the production code, without verifying correct behavior</span></b> of either the original or modified production code. <br /><br /><b><span style="color: purple;">Change detectors provide negative value</span></b>, since the tests do not catch any defects, and the added maintenance cost slows down development. These tests should be re-written or deleted. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-change-detector-tests-considered-harmful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Prefer Testing Public APIs Over Implementation-Detail Classes</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-prefer-testing-public-apis-over-implementation-detail-classes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-prefer-testing-public-apis-over-implementation-detail-classes</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-prefer-testing-public-apis-over-implementation-detail-classes/#comments</comments>
		<pubDate>Wed, 14 Jan 2015 17:30:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=b1e687bba17240a35d8c00fa75f5434d</guid>
		<description><![CDATA[<i>by Andrew Trenk <br /><br />This article was adapted from a  <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a  <a href="https://docs.google.com/document/d/1ILEpaxZ9ntMEXNQuL-q4jWHF0QOAMo45elmomn29cZg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><span><b>Does this class need to have tests?  </b></span><br /><pre><span>class</span> UserInfoValidator {<br /><span>public</span> <span>void</span> validate(UserInfo info) {<br /><span>if</span> (info.getDateOfBirth().isInFuture()) { <span>throw</span> <span>new</span> ValidationException()); }<br />  }<br />}</pre>Its method has some logic, so it may be good idea to test it. But <span><b>what if its only user looks like this?  </b></span><br /><pre><span>public</span> <span>class</span> UserInfoService {<br /><span>private</span> UserInfoValidator validator;<br /><span>public</span> <span>void</span> save(UserInfo info) {<br />    validator.validate(info); <span>// Throw an exception if the value is invalid.</span><br />    writeToDatabase(info);   <br />  }<br />}</pre>The answer is: <span><b>it probably doesn&#8217;t need tests</b></span>, since all paths can be tested through <span>UserInfoService</span>. The key distinction is that <span><b>the class is an implementation detail, not a public API</b></span>.<br /><br /><b><span>A public API can be called by any number of users</span></b>, who can pass in any possible combination of inputs to its methods. <b><span>You want to make sure these are well-tested</span></b>, which ensures users won&#8217;t see issues when they use the API. Examples of public APIs include classes that are used in a different part of a codebase (e.g., a server-side class that&#8217;s used by the client-side) and common utility classes that are used throughout a codebase. <br /><br /><b><span>An implementation-detail class exists only to support public APIs</span></b> and is called by a very limited number of users (often only one). <b><span>These classes can sometimes be tested indirectly</span></b> by testing the public APIs that use them.  <br /><br /><b><span>Testing implementation-detail classes is still useful in many cases</span></b>, such as if the class is complex or if the tests would be difficult to write for the public API class. When you do test them, <b><span>they often don&#8217;t need to be tested in as much depth as a public API,</span></b> since some inputs may never be passed into their methods (in the above code sample, if <span>UserInfoService</span> ensured that <span>UserInfo</span> were never <span>null</span>, then it wouldn&#8217;t be useful to test what happens when <span>null</span> is passed as an argument to <span>UserInfoValidator.validate</span>, since it would never happen). <br /><br />Implementation-detail classes can sometimes be thought of as private methods that happen to be in a separate class, since you typically don&#8217;t want to test private methods directly either. <b><span>You should also try to restrict the visibility of implementation-detail classes,</span></b> such as by making them package-private in Java. <br /><br /><b><span>Testing implementation-detail classes too often leads to a couple problems</span></b>: <br /><br />- <b><span>Code is harder to maintain since you need to update tests more often</span></b>, such as when changing a method signature of an implementation-detail class or even when doing a refactoring. If testing is done only through public APIs, these changes wouldn&#8217;t affect the tests at all. <br /><br />- <b><span>If you test a behavior only through an implementation-detail class, you may get false confidence in your code</span></b>, since the same code path may not work properly when exercised through the public API. <b><span>You also have to be more careful when refactoring</span></b>, since it can be harder to ensure that all the behavior of the public API will be preserved if not all paths are tested through the public API.]]></description>
				<content:encoded><![CDATA[<i>by Andrew Trenk <br /><br />This article was adapted from a  <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a  <a href="https://docs.google.com/document/d/1ILEpaxZ9ntMEXNQuL-q4jWHF0QOAMo45elmomn29cZg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><span style="color: purple;"><b>Does this class need to have tests?  </b></span><br /><pre style="background: #d9ead3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #945200;">class</span> UserInfoValidator {<br />  <span style="color: #945200;">public</span> <span style="color: #945200;">void</span> validate(UserInfo info) {<br />    <span style="color: #945200;">if</span> (info.getDateOfBirth().isInFuture()) { <span style="color: #945200;">throw</span> <span style="color: #945200;">new</span> ValidationException()); }<br />  }<br />}</pre>Its method has some logic, so it may be good idea to test it. But <span style="color: purple;"><b>what if its only user looks like this?  </b></span><br /><pre style="background: #d9ead3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #945200;">public</span> <span style="color: #945200;">class</span> UserInfoService {<br />  <span style="color: #945200;">private</span> UserInfoValidator validator;<br />  <span style="color: #945200;">public</span> <span style="color: #945200;">void</span> save(UserInfo info) {<br />    validator.validate(info); <span style="color: #0096ff;">// Throw an exception if the value is invalid.</span><br />    writeToDatabase(info);   <br />  }<br />}</pre>The answer is: <span style="color: purple;"><b>it probably doesn’t need tests</b></span>, since all paths can be tested through <span style="font-family: Courier New, Courier, monospace;">UserInfoService</span>. The key distinction is that <span style="color: purple;"><b>the class is an implementation detail, not a public API</b></span>.<br /><br /><b><span style="color: purple;">A public API can be called by any number of users</span></b>, who can pass in any possible combination of inputs to its methods. <b><span style="color: purple;">You want to make sure these are well-tested</span></b>, which ensures users won’t see issues when they use the API. Examples of public APIs include classes that are used in a different part of a codebase (e.g., a server-side class that’s used by the client-side) and common utility classes that are used throughout a codebase. <br /><br /><b><span style="color: purple;">An implementation-detail class exists only to support public APIs</span></b> and is called by a very limited number of users (often only one). <b><span style="color: purple;">These classes can sometimes be tested indirectly</span></b> by testing the public APIs that use them.  <br /><br /><b><span style="color: purple;">Testing implementation-detail classes is still useful in many cases</span></b>, such as if the class is complex or if the tests would be difficult to write for the public API class. When you do test them, <b><span style="color: purple;">they often don’t need to be tested in as much depth as a public API,</span></b> since some inputs may never be passed into their methods (in the above code sample, if <span style="font-family: Courier New, Courier, monospace;">UserInfoService</span> ensured that <span style="font-family: Courier New, Courier, monospace;">UserInfo</span> were never <span style="font-family: Courier New, Courier, monospace;">null</span>, then it wouldn’t be useful to test what happens when <span style="font-family: Courier New, Courier, monospace;">null</span> is passed as an argument to <span style="font-family: Courier New, Courier, monospace;">UserInfoValidator.validate</span>, since it would never happen). <br /><br />Implementation-detail classes can sometimes be thought of as private methods that happen to be in a separate class, since you typically don’t want to test private methods directly either. <b><span style="color: purple;">You should also try to restrict the visibility of implementation-detail classes,</span></b> such as by making them package-private in Java. <br /><br /><b><span style="color: purple;">Testing implementation-detail classes too often leads to a couple problems</span></b>: <br /><br />- <b><span style="color: purple;">Code is harder to maintain since you need to update tests more often</span></b>, such as when changing a method signature of an implementation-detail class or even when doing a refactoring. If testing is done only through public APIs, these changes wouldn’t affect the tests at all. <br /><br />- <b><span style="color: purple;">If you test a behavior only through an implementation-detail class, you may get false confidence in your code</span></b>, since the same code path may not work properly when exercised through the public API. <b><span style="color: purple;">You also have to be more careful when refactoring</span></b>, since it can be harder to ensure that all the behavior of the public API will be preserved if not all paths are tested through the public API.]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-prefer-testing-public-apis-over-implementation-detail-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Truth: a fluent assertion framework</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-truth-a-fluent-assertion-framework/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-truth-a-fluent-assertion-framework</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-truth-a-fluent-assertion-framework/#comments</comments>
		<pubDate>Fri, 19 Dec 2014 18:25:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=fbc1c4a27d93a13c37a996869d86021d</guid>
		<description><![CDATA[by Dori Reuveni and Kurt Alfred Kluever This article was adapted from a  Google Testing on the Toilet (TotT) episode. You can download a  printer-friendly version of this TotT episode and post it in your office. As engineers, we spend most of our time ...]]></description>
				<content:encoded><![CDATA[<i>by Dori Reuveni and Kurt Alfred Kluever <br /><br />This article was adapted from a  <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a  <a href="https://docs.google.com/document/d/1TyLthjSGeELWVloxx2hI9l57pNRSN4UVAaNdB7H4Ctg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><b><span style="color: purple;">As engineers, we spend most of our time reading existing code, rather than writing new code.</span></b> Therefore, we must make sure we always write clean, readable code. The same goes for our tests; we need a way to clearly express our test assertions.<br /><br /><b><span style="color: purple;">Truth is an open source, fluent testing framework for Java designed to make your test assertions and failure messages more readable.</span></b> The fluent API makes reading (and writing) test assertions much more natural, prose-like, and discoverable in your IDE via autocomplete. For example, compare how the following assertion reads with JUnit vs. Truth:<br /><pre style="background: #cfe2f3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><b>assertEquals</b>(<span style="color: #ff2600;">"March"</span>, monthMap.get(3));          <span style="color: #4f8f00;">// JUnit</span><br /><b>assertThat</b>(monthMap).<b>containsEntry</b>(3, <span style="color: #ff2600;">"March"</span>);  <span style="color: #4f8f00;">// Truth</span></pre>Both statements are asserting the same thing, but the assertion written with Truth can be easily read from left to right, while the JUnit example requires "mental backtracking".<br /><br /><b><span style="color: purple;">Another benefit of Truth over JUnit is the addition of useful default failure messages</span></b>. For example:<br /><pre style="background: #cfe2f3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">ImmutableSet&lt;String&gt; colors = ImmutableSet.of(<span style="color: #ff2600;">"red"</span>, <span style="color: #ff2600;">"green"</span>, <span style="color: #ff2600;">"blue"</span>, <span style="color: #ff2600;">"yellow"</span>);<br /><b>assertTrue</b>(colors.contains(<span style="color: #ff2600;">"orange"</span>));  <span style="color: #4f8f00;">// JUnit</span><br /><b>assertThat</b>(colors).<b>contains</b>(<span style="color: #ff2600;">"orange"</span>);  <span style="color: #4f8f00;">// Truth</span></pre>In this example, both assertions will fail, but <b><span style="color: purple;">JUnit will not provide a useful failure message</span></b>. However, <span style="color: purple;"><b>Truth will provide a clear and concise failure message</b></span>:<br /><br /><span style="font-family: Courier New, Courier, monospace;">AssertionError: &lt;[red, green, blue, yellow]&gt; should have contained &lt;orange&gt;</span><br /><br /><b><span style="color: purple;">Truth already supports specialized assertions for most of the common JDK types</span></b> (Objects, primitives, arrays, Strings, Classes, Comparables, Iterables, Collections, Lists, Sets, Maps, etc.), as well as some Guava types (Optionals). Additional support for other popular types is planned as well (Throwables, Iterators, Multimaps, UnsignedIntegers, UnsignedLongs, etc.). <br /><br /><b><span style="color: purple;">Truth is also user-extensible: you can easily write a Truth subject to make fluent assertions about your own custom types</span></b>. By creating your own custom subject, both your assertion API and your failure messages can be domain-specific.  <br /><br /><b><span style="color: purple;">Truth's goal is not to replace JUnit assertions, but to improve the readability of complex assertions and their failure messages</span></b>. JUnit assertions and Truth assertions can (and often do) live side by side in tests. <br /><br /><b><span style="color: purple;">To get started with Truth, check out</span></b> <a href="http://google.github.io/truth/">http://google.github.io/truth/</a><br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-truth-a-fluent-assertion-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>GTAC 2014 Wrap-up</title>
		<link>https://googledata.org/google-testing/gtac-2014-wrap-up/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gtac-2014-wrap-up</link>
		<comments>https://googledata.org/google-testing/gtac-2014-wrap-up/#comments</comments>
		<pubDate>Fri, 05 Dec 2014 00:24:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=096b91c0a12ec3b39172479b1d16ce8c</guid>
		<description><![CDATA[by Anthony Vallone on behalf of the GTAC Committee On October 28th and 29th, GTAC 2014, the eighth GTAC (Google Test Automation Conference), was held at the beautiful Google Kirkland office. The conference was completely packed with presenters and atte...]]></description>
				<content:encoded><![CDATA[<i>by Anthony Vallone on behalf of the GTAC Committee </i><br /><br />On October 28th and 29th, <a href="https://developers.google.com/google-test-automation-conference/2014/">GTAC 2014</a>, the eighth GTAC (Google Test Automation Conference), was held at the beautiful <a href="http://www.google.com/about/careers/locations/seattle-kirkland/">Google Kirkland office</a>. The conference was completely packed with presenters and attendees from all over the world (<i>Argentina, Australia, Canada, China, many European countries, India, Israel, Korea, New Zealand, Puerto Rico, Russia, Taiwan, and many US states</i>), bringing with them a huge diversity of experiences.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-AsIoO6UVjSg/VID5DtgkaeI/AAAAAAAAAHM/VJMsLWzhKZw/s1600/gtac-reception.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-AsIoO6UVjSg/VID5DtgkaeI/AAAAAAAAAHM/VJMsLWzhKZw/s1600/gtac-reception.jpg" height="266" width="400" /></a></div><br />Speakers from numerous companies and universities (<i>Adobe, American Express, Comcast, Dropbox, Facebook, FINRA, Google, HP, Medidata Solutions, Mozilla, Netflix, Orange, and University of Waterloo</i>) spoke on a variety of interesting and cutting edge test automation topics.<br /><br />All of the <a href="https://developers.google.com/google-test-automation-conference/2014/presentations">slides and video recordings</a> are now available on the GTAC site. Photos will be available soon as well.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-vFVJPsUDf5w/VID5J4eHzRI/AAAAAAAAAHU/td0jYOzgLlM/s1600/gtac-crowd.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-vFVJPsUDf5w/VID5J4eHzRI/AAAAAAAAAHU/td0jYOzgLlM/s1600/gtac-crowd.jpg" height="266" width="400" /></a></div><br />This was our most popular GTAC to date, with over 1,500 applicants and almost 200 of those for speaking. About 250 people filled our venue to capacity, and the live stream had a peak of about 400 concurrent viewers with 4,700 playbacks during the event. And, there was plenty of interesting <a href="https://twitter.com/search?q=%23gtac2014">Twitter</a> and <a href="https://plus.google.com/u/0/explore/gtac2014">Google+</a> activity during the event.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-99JJwZlZacE/VID5LooJXyI/AAAAAAAAAHc/u5QJvNmlTiw/s1600/gtac-eat.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-99JJwZlZacE/VID5LooJXyI/AAAAAAAAAHc/u5QJvNmlTiw/s1600/gtac-eat.jpg" height="266" width="400" /></a></div><br />Our goal in hosting GTAC is to make the conference highly relevant and useful for, not only attendees, but the larger test engineering community as a whole. Our post-conference survey shows that we are close to achieving that goal: <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-9B3NGNXAyyI/VID5NcheskI/AAAAAAAAAHk/0WPeJvqiPKU/s1600/gtac-stats.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-9B3NGNXAyyI/VID5NcheskI/AAAAAAAAAHk/0WPeJvqiPKU/s1600/gtac-stats.png" height="154" width="640" /></a></div><br /><br />If you have any suggestions on how we can improve, please comment on this post. <br /><br />Thank you to all the <a href="https://developers.google.com/google-test-automation-conference/2014/speakers">speakers</a>, attendees, and online viewers who made this a special event once again. To receive announcements about the next GTAC, subscribe to the <a href="http://googletesting.blogspot.com/">Google Testing Blog</a>. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/gtac-2014-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Protractor: Angular testing made easy</title>
		<link>https://googledata.org/google-testing/protractor-angular-testing-made-easy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=protractor-angular-testing-made-easy</link>
		<comments>https://googledata.org/google-testing/protractor-angular-testing-made-easy/#comments</comments>
		<pubDate>Sun, 30 Nov 2014 17:46:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=cbd3bf2958b53751e8878580c24ec4bc</guid>
		<description><![CDATA[<i>By Hank Duan, Julie Ralph, and Arif Sukoco in Seattle </i><br /><br />Have you worked with WebDriver but been frustrated with all the waits needed for WebDriver to sync with the website, causing flakes and prolonged test times? If you are working with AngularJS apps, then Protractor is the right tool for you. <br /><br />Protractor (<a href="http://protractortest.org/">protractortest.org</a>) is an end-to-end test framework specifically for AngularJS apps. It was built by a team in Google and released to open source. Protractor is built on top of WebDriverJS and includes important improvements tailored for AngularJS apps. Here are some of Protractor&#8217;s key benefits:<br /><br /><ul><li><b>You don&#8217;t need to add waits or sleeps to your test</b>. Protractor can communicate with your AngularJS app automatically and execute the next step in your test the moment the webpage finishes pending tasks, so you don&#8217;t have to worry about waiting for your test and webpage to sync.&#160;</li><li><b>It supports Angular-specific locator strategies</b> (e.g., binding, model, repeater) as well as native WebDriver locator strategies (e.g., ID, CSS selector, XPath). This allows you to test Angular-specific elements without any setup effort on your part.&#160;</li><li><b>It is easy to set up page objects</b>. Protractor does not execute WebDriver commands until an action is needed (e.g., get, sendKeys, click). This way you can set up page objects so tests can manipulate page elements without touching the HTML.&#160;</li><li><b>It uses Jasmine</b>, the framework you use to write AngularJS unit tests, <b>and Javascript</b>, the same language you use to write AngularJS apps.</li></ul><br />Follow these simple steps, and in minutes, you will have you first Protractor test running:  <br /><br /><b>1) Set up environment </b><br /><br />Install the command line tools &#8216;protractor&#8217; and &#8216;webdriver-manager&#8217; using npm:<br /><pre>npm install -g protractor</pre><br />Start up an instance of a selenium server:<br /><pre>webdriver-manager update &#38; webdriver-manager start</pre><br />This downloads the necessary binary, and starts a new webdriver session listening on <a href="http://localhost:4444/">http://localhost:4444</a>. <br /><br /><b>2) Write your test</b><br /><pre><span>// It is a good idea to use page objects to modularize your testing logic</span><br />var angularHomepage = {<br />  nameInput : element(by.model(<span>'yourName'</span>)),<br />  greeting : element(by.binding(<span>'yourName'</span>)),<br />  get : function() {<br />    browser.get(<span>'index.html'</span>);<br />  },<br />  setName : function(name) {<br /><span>this</span>.nameInput.sendKeys(name);<br />  }<br />};<br /><br /><span>// Here we are using the Jasmine test framework </span><br /><span>// See http://jasmine.github.io/2.0/introduction.html for more details</span><br />describe(<span>'angularjs homepage'</span>, function() {<br />  it(<span>'should greet the named user'</span>, function(){<br />    angularHomepage.get();<br />    angularHomepage.setName(<span>'Julie'</span>);<br />    expect(angularHomepage.greeting.getText()).<br />        toEqual(<span>'Hello Julie!'</span>);<br />  });<br />});</pre><br />3) Write a Protractor configuration file to specify the environment under which you want your test to run:<br /><pre>exports.config = {<br />  seleniumAddress: <span>'http://localhost:4444/wd/hub'</span>,<br /><br />  specs: [<span>'testFolder/*'</span>],<br /><br />  multiCapabilities: [{<br /><span>'browserName'</span>: <span>'chrome'</span>,<br /><span>// browser-specific tests</span><br />    specs: <span>'chromeTests/*'</span> <br />  }, {<br /><span>'browserName'</span>: <span>'firefox'</span>,<br /><span>// run tests in parallel</span><br />    shardTestFiles: <span>true</span> <br />  }],<br /><br />  baseUrl: <span>'http://www.angularjs.org'</span>,<br />};</pre><br />4) Run the test: <br /><br />Start the test with the command: <br /><pre>protractor conf.js</pre><br />The test output should be: <br /><pre>1 test, 1 assertions, 0 failures</pre><br /><br />If you want to learn more, here&#8217;s a full tutorial that highlights all of Protractor&#8217;s features: <a href="http://angular.github.io/protractor/#/tutorial">http://angular.github.io/protractor/#/tutorial </a><br /><br />]]></description>
				<content:encoded><![CDATA[<i>By Hank Duan, Julie Ralph, and Arif Sukoco in Seattle </i><br /><br />Have you worked with WebDriver but been frustrated with all the waits needed for WebDriver to sync with the website, causing flakes and prolonged test times? If you are working with AngularJS apps, then Protractor is the right tool for you. <br /><br />Protractor (<a href="http://protractortest.org/">protractortest.org</a>) is an end-to-end test framework specifically for AngularJS apps. It was built by a team in Google and released to open source. Protractor is built on top of WebDriverJS and includes important improvements tailored for AngularJS apps. Here are some of Protractor’s key benefits:<br /><br /><ul style="line-height: 1.3em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li><b>You don’t need to add waits or sleeps to your test</b>. Protractor can communicate with your AngularJS app automatically and execute the next step in your test the moment the webpage finishes pending tasks, so you don’t have to worry about waiting for your test and webpage to sync.&nbsp;</li><li><b>It supports Angular-specific locator strategies</b> (e.g., binding, model, repeater) as well as native WebDriver locator strategies (e.g., ID, CSS selector, XPath). This allows you to test Angular-specific elements without any setup effort on your part.&nbsp;</li><li><b>It is easy to set up page objects</b>. Protractor does not execute WebDriver commands until an action is needed (e.g., get, sendKeys, click). This way you can set up page objects so tests can manipulate page elements without touching the HTML.&nbsp;</li><li><b>It uses Jasmine</b>, the framework you use to write AngularJS unit tests, <b>and Javascript</b>, the same language you use to write AngularJS apps.</li></ul><br />Follow these simple steps, and in minutes, you will have you first Protractor test running:  <br /><br /><b>1) Set up environment </b><br /><br />Install the command line tools ‘protractor’ and ‘webdriver-manager’ using npm:<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">npm install -g protractor</pre><br />Start up an instance of a selenium server:<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">webdriver-manager update &amp; webdriver-manager start</pre><br />This downloads the necessary binary, and starts a new webdriver session listening on <a href="http://localhost:4444/">http://localhost:4444</a>. <br /><br /><b>2) Write your test</b><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #4f8f00;">// It is a good idea to use page objects to modularize your testing logic</span><br />var angularHomepage = {<br />  nameInput : element(by.model(<span style="color: #ff2600;">'yourName'</span>)),<br />  greeting : element(by.binding(<span style="color: #ff2600;">'yourName'</span>)),<br />  get : function() {<br />    browser.get(<span style="color: #ff2600;">'index.html'</span>);<br />  },<br />  setName : function(name) {<br />    <span style="color: #0433ff;">this</span>.nameInput.sendKeys(name);<br />  }<br />};<br /><br /><span style="color: #4f8f00;">// Here we are using the Jasmine test framework </span><br /><span style="color: #4f8f00;">// See http://jasmine.github.io/2.0/introduction.html for more details</span><br />describe(<span style="color: #ff2600;">'angularjs homepage'</span>, function() {<br />  it(<span style="color: #ff2600;">'should greet the named user'</span>, function(){<br />    angularHomepage.get();<br />    angularHomepage.setName(<span style="color: #ff2600;">'Julie'</span>);<br />    expect(angularHomepage.greeting.getText()).<br />        toEqual(<span style="color: #ff2600;">'Hello Julie!'</span>);<br />  });<br />});</pre><br />3) Write a Protractor configuration file to specify the environment under which you want your test to run:<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">exports.config = {<br />  seleniumAddress: <span style="color: #ff2600;">'http://localhost:4444/wd/hub'</span>,<br />  <br />  specs: [<span style="color: #ff2600;">'testFolder/*'</span>],<br /><br />  multiCapabilities: [{<br />    <span style="color: #ff2600;">'browserName'</span>: <span style="color: #ff2600;">'chrome'</span>,<br />    <span style="color: #4f8f00;">// browser-specific tests</span><br />    specs: <span style="color: #ff2600;">'chromeTests/*'</span> <br />  }, {<br />    <span style="color: #ff2600;">'browserName'</span>: <span style="color: #ff2600;">'firefox'</span>,<br />    <span style="color: #4f8f00;">// run tests in parallel</span><br />    shardTestFiles: <span style="color: #0433ff;">true</span> <br />  }],<br /><br />  baseUrl: <span style="color: #ff2600;">'http://www.angularjs.org'</span>,<br />};</pre><br />4) Run the test: <br /><br />Start the test with the command: <br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">protractor conf.js</pre><br />The test output should be: <br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">1 test, 1 assertions, 0 failures</pre><br /><br />If you want to learn more, here’s a full tutorial that highlights all of Protractor’s features: <a href="http://angular.github.io/protractor/#/tutorial">http://angular.github.io/protractor/#/tutorial </a><br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/protractor-angular-testing-made-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>GTAC 2014 is this Week!</title>
		<link>https://googledata.org/google-testing/gtac-2014-is-this-week/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gtac-2014-is-this-week</link>
		<comments>https://googledata.org/google-testing/gtac-2014-is-this-week/#comments</comments>
		<pubDate>Mon, 27 Oct 2014 18:26:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=b3c5e24cfb9f2949e703eed2ec89d3fa</guid>
		<description><![CDATA[by Anthony Vallone on behalf of the GTAC Committee  The eighth GTAC commences on Tuesday at the Google Kirkland office. You can find the latest details on the conference at our site, including speaker profiles. If you are watching remotely, we'll soon ...]]></description>
				<content:encoded><![CDATA[<i>by Anthony Vallone on behalf of the GTAC Committee  </i><br /><br />The eighth GTAC commences on Tuesday at the Google Kirkland office. You can find the latest details on the conference at our site, including <a href="https://developers.google.com/google-test-automation-conference/2014/speakers">speaker profiles</a>. <br /><br />If you are watching remotely, we'll soon be updating the <a href="https://developers.google.com/google-test-automation-conference/2014/stream">live stream page</a> with the stream link and a Google Moderator link for remote Q&amp;A. <br /><br />If you have been selected to attend or speak, be sure to note the <a href="https://developers.google.com/google-test-automation-conference/2014/travel">updated parking information</a>. Google visitors will use off-site parking and shuttles. <br /><br />We look forward to connecting with the greater testing community and sharing new advances and ideas. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/gtac-2014-is-this-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Writing Descriptive Test Names</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-writing-descriptive-test-names/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-writing-descriptive-test-names</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-writing-descriptive-test-names/#comments</comments>
		<pubDate>Thu, 16 Oct 2014 20:39:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=0ba0096d1178bf588125ce40628a334a</guid>
		<description><![CDATA[<i>by Andrew Trenk </i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1UzvzMUkv0mpIFjrLqTcqvHFC5_1ycOCmrMVt-ubR2ec/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><b><span>How long does it take you to figure out what behavior is being tested in the following code? </span></b><br /><br /><pre>@Test <span>public</span> <span>void</span> <b>isUserLockedOut_invalidLogin</b>() {<br /><b>authenticator</b>.authenticate(<b>username</b>, <b>invalidPassword</b>);<br />  assertFalse(<b>authenticator</b>.isUserLockedOut(<b>username</b>));<br /><br /><b>authenticator</b>.authenticate(<b>username</b>, <b>invalidPassword</b>);<br />  assertFalse(<b>authenticator</b>.isUserLockedOut(<b>username</b>));<br /><br /><b>authenticator</b>.authenticate(<b>username</b>, <b>invalidPassword</b>);<br />  assertTrue(<b>authenticator</b>.isUserLockedOut(<b>username</b>));<br />}</pre><br /><b><span>You probably had to read through every line of code</span></b> (maybe more than once) and understand what each line is doing. But <b><span>how long would it take you to figure out what behavior is being tested if the test had this name?</span></b><br /><br /><b><span>isUserLockedOut_lockOutUserAfterThreeInvalidLoginAttempts</span></b><br /><b><br /></b><b><span>You should now be able to understand what behavior is being tested by reading just the test name</span></b>, and you don&#8217;t even need to read through the test body. The test name in the above code sample hints at the scenario being tested (&#8220;invalidLogin&#8221;), but it doesn&#8217;t actually say what the expected outcome is supposed to be, so you had to read through the code to figure it out. <br /><br /><b><span>Putting both the scenario and the expected outcome in the test name has several other benefits: </span></b><br /><br />- <b><span>If you want to know all the possible behaviors a class has, all you need to do is read through the test names in its test class</span></b>, compared to spending minutes or hours digging through the test code or even the class itself trying to figure out its behavior. This can also be useful during code reviews since you can quickly tell if the tests cover all expected cases. <br /><br />- <b><span>By giving tests more explicit names, it forces you to split up testing different behaviors into separate tests</span></b>. Otherwise you may be tempted to dump assertions for different behaviors into one test, which over time can lead to tests that keep growing and become difficult to understand and maintain. <br /><br />- <b><span>The exact behavior being tested might not always be clear from the test code</span></b>. If the test name isn&#8217;t explicit about this, sometimes you might have to guess what the test is actually testing. <br /><br />- <b><span>You can easily tell if some functionality isn&#8217;t being tested</span></b>. If you don&#8217;t see a test name that describes the behavior you&#8217;re looking for, then you know the test doesn&#8217;t exist.  <br /><br />- <b><span>When a test fails, you can immediately see what functionality is broken without looking at the test&#8217;s source code</span></b>. <br /><br />There are several common patterns for structuring the name of a test (one example is to name tests like an English sentence with &#8220;should&#8221; in the name, e.g., <span>shouldLockOutUserAfterThreeInvalidLoginAttempts</span>). Whichever pattern you use, the same advice still applies: <span><b>Make sure test names contain both the scenario being tested and the expected outcome</b></span>.  <br /><br />Sometimes just specifying the name of the method under test may be enough, especially if the method is simple and has only a single behavior that is obvious from its name.  <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Andrew Trenk </i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1UzvzMUkv0mpIFjrLqTcqvHFC5_1ycOCmrMVt-ubR2ec/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><b><span style="color: #990000;">How long does it take you to figure out what behavior is being tested in the following code? </span></b><br /><br /><pre style="background: #fff2cc; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">@Test <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> <b>isUserLockedOut_invalidLogin</b>() {<br />  <b>authenticator</b>.authenticate(<b>username</b>, <b>invalidPassword</b>);<br />  assertFalse(<b>authenticator</b>.isUserLockedOut(<b>username</b>));<br /><br />  <b>authenticator</b>.authenticate(<b>username</b>, <b>invalidPassword</b>);<br />  assertFalse(<b>authenticator</b>.isUserLockedOut(<b>username</b>));<br /><br />  <b>authenticator</b>.authenticate(<b>username</b>, <b>invalidPassword</b>);<br />  assertTrue(<b>authenticator</b>.isUserLockedOut(<b>username</b>));<br />}</pre><br /><b><span style="color: #990000;">You probably had to read through every line of code</span></b> (maybe more than once) and understand what each line is doing. But <b><span style="color: #990000;">how long would it take you to figure out what behavior is being tested if the test had this name?</span></b><br /><br /><b><span style="font-family: Courier New, Courier, monospace;">isUserLockedOut_lockOutUserAfterThreeInvalidLoginAttempts</span></b><br /><b><br /></b><b><span style="color: #990000;">You should now be able to understand what behavior is being tested by reading just the test name</span></b>, and you don’t even need to read through the test body. The test name in the above code sample hints at the scenario being tested (“invalidLogin”), but it doesn’t actually say what the expected outcome is supposed to be, so you had to read through the code to figure it out. <br /><br /><b><span style="color: #990000;">Putting both the scenario and the expected outcome in the test name has several other benefits: </span></b><br /><br />- <b><span style="color: #990000;">If you want to know all the possible behaviors a class has, all you need to do is read through the test names in its test class</span></b>, compared to spending minutes or hours digging through the test code or even the class itself trying to figure out its behavior. This can also be useful during code reviews since you can quickly tell if the tests cover all expected cases. <br /><br />- <b><span style="color: #990000;">By giving tests more explicit names, it forces you to split up testing different behaviors into separate tests</span></b>. Otherwise you may be tempted to dump assertions for different behaviors into one test, which over time can lead to tests that keep growing and become difficult to understand and maintain. <br /><br />- <b><span style="color: #990000;">The exact behavior being tested might not always be clear from the test code</span></b>. If the test name isn’t explicit about this, sometimes you might have to guess what the test is actually testing. <br /><br />- <b><span style="color: #990000;">You can easily tell if some functionality isn’t being tested</span></b>. If you don’t see a test name that describes the behavior you’re looking for, then you know the test doesn’t exist.  <br /><br />- <b><span style="color: #990000;">When a test fails, you can immediately see what functionality is broken without looking at the test’s source code</span></b>. <br /><br />There are several common patterns for structuring the name of a test (one example is to name tests like an English sentence with “should” in the name, e.g., <span style="font-family: Courier New, Courier, monospace;">shouldLockOutUserAfterThreeInvalidLoginAttempts</span>). Whichever pattern you use, the same advice still applies: <span style="color: #990000;"><b>Make sure test names contain both the scenario being tested and the expected outcome</b></span>.  <br /><br />Sometimes just specifying the name of the method under test may be enough, especially if the method is simple and has only a single behavior that is obvious from its name.  <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-writing-descriptive-test-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Announcing the GTAC 2014 Agenda</title>
		<link>https://googledata.org/google-testing/announcing-the-gtac-2014-agenda/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=announcing-the-gtac-2014-agenda</link>
		<comments>https://googledata.org/google-testing/announcing-the-gtac-2014-agenda/#comments</comments>
		<pubDate>Wed, 01 Oct 2014 00:36:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=e1f9e0b7793151892e50873d9142e1d8</guid>
		<description><![CDATA[<i>by Anthony Vallone on behalf of the GTAC Committee  </i><br /><br />We have completed selection and confirmation of all speakers and attendees for GTAC 2014. You can find the detailed agenda at: <br />&#160;&#160;<a href="http://developers.google.com/gtac/2014/schedule">developers.google.com/gtac/2014/schedule</a><br /><br />Thank you to all who submitted proposals! It was very hard to make selections from so many fantastic submissions. <br /><br />There was a tremendous amount of interest in GTAC this year with over 1,500 applicants (up from 533 last year) and 194 of those for speaking (up from 88 last year). Unfortunately, our venue only seats 250. However, don&#8217;t despair if you did not receive an invitation. Just like last year, anyone can join us via <a href="https://developers.google.com/google-test-automation-conference/2014/stream">YouTube live streaming</a>. We&#8217;ll also be setting up Google Moderator, so remote attendees can get involved in Q&#38;A after each talk. Information about live streaming, Moderator, and other details will be posted on the GTAC site soon and announced here. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Anthony Vallone on behalf of the GTAC Committee  </i><br /><br />We have completed selection and confirmation of all speakers and attendees for GTAC 2014. You can find the detailed agenda at: <br />&nbsp;&nbsp;<a href="http://developers.google.com/gtac/2014/schedule">developers.google.com/gtac/2014/schedule</a><br /><br />Thank you to all who submitted proposals! It was very hard to make selections from so many fantastic submissions. <br /><br />There was a tremendous amount of interest in GTAC this year with over 1,500 applicants (up from 533 last year) and 194 of those for speaking (up from 88 last year). Unfortunately, our venue only seats 250. However, don’t despair if you did not receive an invitation. Just like last year, anyone can join us via <a href="https://developers.google.com/google-test-automation-conference/2014/stream">YouTube live streaming</a>. We’ll also be setting up Google Moderator, so remote attendees can get involved in Q&amp;A after each talk. Information about live streaming, Moderator, and other details will be posted on the GTAC site soon and announced here. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/announcing-the-gtac-2014-agenda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Chrome &#8211; Firefox WebRTC Interop Test &#8211; Pt 2</title>
		<link>https://googledata.org/google-testing/chrome-firefox-webrtc-interop-test-pt-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=chrome-firefox-webrtc-interop-test-pt-2</link>
		<comments>https://googledata.org/google-testing/chrome-firefox-webrtc-interop-test-pt-2/#comments</comments>
		<pubDate>Tue, 09 Sep 2014 20:05:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=dc693df5a565e711d4e34e188f2d176c</guid>
		<description><![CDATA[<i>by Patrik H&#246;glund </i><br /><i><br /></i><i>This is the second in a series of articles about Chrome&#8217;s WebRTC Interop Test. <a href="http://googletesting.blogspot.com/2014/08/chrome-firefox-webrtc-interop-test-pt-1.html">See the first</a>.</i><br /><br />In the previous blog post we managed to write an automated test which got a WebRTC call between Firefox and Chrome to run. But how do we verify that the call actually worked?<br /><br /><h3>Verifying the Call</h3>Now we can launch the two browsers, but how do we figure out the whether the call actually worked? If you try opening two <a href="http://apprtc.appspot.com/">apprtc.appspot.com</a> tabs in the same room, you will notice the video feeds flip over using a CSS transform, your local video is relegated to a small frame and a new big video feed with the remote video shows up. For the first version of the test, I just looked at the page in the Chrome debugger and looked for some reliable signal. As it turns out, the <span><b>remoteVideo.style.opacity</b></span> property will go from 0 to 1 when the call goes up and from 1 to 0 when it goes down. Since we can execute arbitrary JavaScript in the Chrome tab from the test, we can simply implement the check like this: <br /><br /><pre><span>bool</span> WaitForCallToComeUp(content::WebContents* tab_contents) {<br /><span>// Apprtc will set remoteVideo.style.opacity to 1 when the call comes up.</span><br />  std::<span>string</span> javascript =<br /><span>"window.domAutomationController.send(remoteVideo.style.opacity)"</span>;<br /><span>return</span> test::PollingWaitUntil(javascript, <span>"1"</span>, tab_contents);<br />}<br /></pre><br /><h3>Verifying Video is Playing</h3>So getting a call up is good, but what if there is a bug where Firefox and Chrome cannot send correct video streams to each other? To check that, we needed to step up our game a bit. We decided to use our <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/test/data/webrtc/video_detector.js&#38;q=video_dete&#38;sq=package:chromium&#38;l=1">existing video detector</a>, which looks at a video element and determines if the pixels are changing. This is a very basic check, but it&#8217;s better than nothing. To do this, we simply evaluate the .js file&#8217;s JavaScript in the context of the Chrome tab, making the functions in the file available to us. The implementation then becomes <br /><br /><pre><span>bool</span> DetectRemoteVideoPlaying(content::WebContents* tab_contents) {<br /><span>if</span> (!EvalInJavascriptFile(tab_contents, GetSourceDir().Append(<br />      FILE_PATH_LITERAL(<br /><span>"chrome/test/data/webrtc/test_functions.js"</span>))))<br /><span>return</span> <span>false</span>;<br /><span>if</span> (!EvalInJavascriptFile(tab_contents, GetSourceDir().Append(<br />      FILE_PATH_LITERAL(<br /><span>"chrome/test/data/webrtc/video_detector.js"</span>))))<br /><span>return</span> <span>false</span>;<br /><br /><span>// The remote video tag is called remoteVideo in the AppRTC code.</span><br />  StartDetectingVideo(tab_contents, <span>"remoteVideo"</span>);<br />  WaitForVideoToPlay(tab_contents);<br /><span>return</span> <span>true</span>;<br />}</pre><br />where <span><b>StartDetectingVideo</b></span> and <span><b>WaitForVideoToPlay</b></span> call the corresponding JavaScript methods in <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/test/data/webrtc/video_detector.js&#38;q=video_dete&#38;sq=package:chromium&#38;l=61">video_detector.js</a>. If the video feed is frozen and unchanging, the test will time out and fail.<br /><br /><h3>What to Send in the Call</h3>Now we can get a call up between the browsers and detect if video is playing. But what video should we send? For chrome, we have a convenient <span><b>--use-fake-device-for-media-stream</b></span> flag that will make Chrome pretend there&#8217;s a webcam and present a generated video feed (which is a spinning green ball with a timestamp). This turned out to be useful since Firefox and Chrome cannot acquire the same camera at the same time, so if we didn&#8217;t use the fake device we would have two webcams plugged into the bots executing the tests! <br /><br />Bots running in Chrome&#8217;s <a href="http://build.chromium.org/">regular test infrastructure</a> do not have either software or hardware webcams plugged into them, so this test must run on bots with webcams for Firefox to be able to acquire a camera. Fortunately, we have that in the <a href="http://build.chromium.org/p/chromium.webrtc/waterfall">WebRTC waterfalls</a> in order to test that we can actually acquire hardware webcams on all platforms. We also added a check to just succeed the test when there&#8217;s no real webcam on the system since we don&#8217;t want it to fail when a dev runs it on a machine without a webcam:  <br /><br /><pre><span>if</span> (!HasWebcamOnSystem())<br /><span>return</span>;<br /></pre><br />It would of course be better if Firefox had a similar fake device, but to my knowledge it doesn&#8217;t.<br /><br /><h3>Downloading all Code and Components&#160;</h3>Now we have all we need to run the test and have it verify something useful. We just have the hard part left: how do we actually download all the resources we need to run this test? Recall that this is actually a three-way integration test between Chrome, Firefox and AppRTC, which require the following:<br /><br /><ul><li>The AppEngine SDK in order to bring up the local AppRTC instance,&#160;</li><li>The AppRTC code itself,&#160;</li><li>Chrome (already present in the checkout), and&#160;</li><li>Firefox nightly.</li></ul><br />While developing the test, I initially just hand-downloaded these and installed and hard-coded the paths. This is a very bad idea in the long run. Recall that the Chromium infrastructure is comprised of <a href="http://build.chromium.org/">thousands and thousands of machines</a>, and while this test will only run on perhaps 5 at a time due to its webcam requirements, we don&#8217;t want manual maintenance work whenever we replace a machine. And for that matter, we definitely don&#8217;t want to download a new Firefox by hand every night and put it on the right location on the bots! So how do we automate this? <br /><br /><b>Downloading the AppEngine SDK</b><br />First, let&#8217;s start with the easy part. We don&#8217;t really care if the AppEngine SDK is up-to-date, so a relatively stale version is fine. We could have the test download it from the <a href="https://developers.google.com/appengine/downloads">authoritative source</a>, but that&#8217;s a bad idea for a couple reasons. First, it updates outside our control. Second, there could be anti-robot measures on the page. Third, the download will likely be unreliable and fail the test occasionally. <br /><br />The way we solved this was to upload a copy of the SDK to a <a href="https://cloud.google.com/products/cloud-storage/?utm_source=google&#38;utm_medium=cpc&#38;utm_campaign=cloudstorage-search">Google storage</a> bucket under our control and download it using the <a href="http://dev.chromium.org/developers/how-tos/depottools">depot_tools</a> script <span><b>download_from_google_storage.py</b></span>. This is a lot more reliable than an external website and will not download the SDK if we already have the right version on the bot. <br /><br /><b>Downloading the AppRTC Code</b><br />This code is on GitHub. Experience has shown that git clone commands run against GitHub will fail every now and then, and fail the test. We could either write some retry mechanism, but we have found it&#8217;s better to simply mirror the git repository in Chromium&#8217;s internal mirrors, which are closer to our bots and thereby more reliable from our perspective. The pull is done by a <a href="http://chromegw/viewvc/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/DEPS?revision=262390&#38;view=markup">Chromium DEPS file</a> (which is Chromium&#8217;s dependency provisioning framework). <br /><br /><b>Downloading Firefox</b><br />It turns out that Firefox supplies handy libraries for this task. We&#8217;re using mozdownload <a href="http://chromegw/viewvc/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/download_firefox_nightly.py?revision=241269&#38;view=markup">in this script</a> in order to download the Firefox nightly build. Unfortunately this <a href="https://code.google.com/p/chromium/issues/detail?id=360516">fails every now and then</a> so we would like to have some retry mechanism, or we could write some mechanism to &#8220;mirror&#8221; the Firefox nightly build in some location we control.<br /><br /><h3>Putting it Together</h3>With that, we have everything we need to deploy the test. You can see the <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc&#38;q=chrome_webrtc_app&#38;sq=package:chromium&#38;l=297">final code here</a>.  <br /><br />The provisioning code above was put into a separate &#8220;<a href="http://chromegw/viewvc/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/">.gclient solution</a>&#8221; so that regular Chrome devs and bots are not burdened with downloading hundreds of megs of SDKs and code that they will not use. When this test runs, you will first see a Chrome browser pop up, which will ensure the local apprtc instance is up. Then a Firefox browser will pop up. They will each acquire the fake device and real camera, respectively, and after a short delay the AppRTC call will come up, proving that video interop is working. <br /><br />This is a complicated and expensive test, but we believe it is worth it to keep the main interop case under automation this way, especially as the spec evolves and the browsers are in varying states of implementation. <br /><br />Future Work<br /><br /><ul><li>Also run on Windows/Mac.&#160;</li><li>Also test Opera.&#160;</li><li>Interop between Chrome/Firefox mobile and desktop browsers.&#160;</li><li>Also ensure audio is playing.&#160;</li><li>Measure bandwidth stats, video quality, etc.</li></ul><br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Patrik Höglund </i><br /><i><br /></i><i>This is the second in a series of articles about Chrome’s WebRTC Interop Test. <a href="http://googletesting.blogspot.com/2014/08/chrome-firefox-webrtc-interop-test-pt-1.html">See the first</a>.</i><br /><br />In the previous blog post we managed to write an automated test which got a WebRTC call between Firefox and Chrome to run. But how do we verify that the call actually worked?<br /><br /><h3>Verifying the Call</h3>Now we can launch the two browsers, but how do we figure out the whether the call actually worked? If you try opening two <a href="http://apprtc.appspot.com/">apprtc.appspot.com</a> tabs in the same room, you will notice the video feeds flip over using a CSS transform, your local video is relegated to a small frame and a new big video feed with the remote video shows up. For the first version of the test, I just looked at the page in the Chrome debugger and looked for some reliable signal. As it turns out, the <span style="color: #6aa84f; font-family: Courier New, Courier, monospace;"><b>remoteVideo.style.opacity</b></span> property will go from 0 to 1 when the call goes up and from 1 to 0 when it goes down. Since we can execute arbitrary JavaScript in the Chrome tab from the test, we can simply implement the check like this: <br /><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">bool</span> WaitForCallToComeUp(content::WebContents* tab_contents) {<br />  <span style="color: #4f8f00;">// Apprtc will set remoteVideo.style.opacity to 1 when the call comes up.</span><br />  std::<span style="color: #0433ff;">string</span> javascript =<br />      <span style="color: #ff2600;">"window.domAutomationController.send(remoteVideo.style.opacity)"</span>;<br />  <span style="color: #0433ff;">return</span> test::PollingWaitUntil(javascript, <span style="color: #ff2600;">"1"</span>, tab_contents);<br />}<br /></pre><br /><h3>Verifying Video is Playing</h3>So getting a call up is good, but what if there is a bug where Firefox and Chrome cannot send correct video streams to each other? To check that, we needed to step up our game a bit. We decided to use our <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/test/data/webrtc/video_detector.js&amp;q=video_dete&amp;sq=package:chromium&amp;l=1">existing video detector</a>, which looks at a video element and determines if the pixels are changing. This is a very basic check, but it’s better than nothing. To do this, we simply evaluate the .js file’s JavaScript in the context of the Chrome tab, making the functions in the file available to us. The implementation then becomes <br /><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">bool</span> DetectRemoteVideoPlaying(content::WebContents* tab_contents) {<br />  <span style="color: #0433ff;">if</span> (!EvalInJavascriptFile(tab_contents, GetSourceDir().Append(<br />      FILE_PATH_LITERAL(<br />          <span style="color: #ff2600;">"chrome/test/data/webrtc/test_functions.js"</span>))))<br />    <span style="color: #0433ff;">return</span> <span style="color: #0433ff;">false</span>;<br />  <span style="color: #0433ff;">if</span> (!EvalInJavascriptFile(tab_contents, GetSourceDir().Append(<br />      FILE_PATH_LITERAL(<br />          <span style="color: #ff2600;">"chrome/test/data/webrtc/video_detector.js"</span>))))<br />    <span style="color: #0433ff;">return</span> <span style="color: #0433ff;">false</span>;<br /><br />  <span style="color: #4f8f00;">// The remote video tag is called remoteVideo in the AppRTC code.</span><br />  StartDetectingVideo(tab_contents, <span style="color: #ff2600;">"remoteVideo"</span>);<br />  WaitForVideoToPlay(tab_contents);<br />  <span style="color: #0433ff;">return</span> <span style="color: #0433ff;">true</span>;<br />}</pre><br />where <span style="color: #6aa84f; font-family: Courier New, Courier, monospace;"><b>StartDetectingVideo</b></span> and <span style="color: #6aa84f; font-family: Courier New, Courier, monospace;"><b>WaitForVideoToPlay</b></span> call the corresponding JavaScript methods in <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/test/data/webrtc/video_detector.js&amp;q=video_dete&amp;sq=package:chromium&amp;l=61">video_detector.js</a>. If the video feed is frozen and unchanging, the test will time out and fail.<br /><br /><h3>What to Send in the Call</h3>Now we can get a call up between the browsers and detect if video is playing. But what video should we send? For chrome, we have a convenient <span style="color: #6aa84f; font-family: Courier New, Courier, monospace;"><b>--use-fake-device-for-media-stream</b></span> flag that will make Chrome pretend there’s a webcam and present a generated video feed (which is a spinning green ball with a timestamp). This turned out to be useful since Firefox and Chrome cannot acquire the same camera at the same time, so if we didn’t use the fake device we would have two webcams plugged into the bots executing the tests! <br /><br />Bots running in Chrome’s <a href="http://build.chromium.org/">regular test infrastructure</a> do not have either software or hardware webcams plugged into them, so this test must run on bots with webcams for Firefox to be able to acquire a camera. Fortunately, we have that in the <a href="http://build.chromium.org/p/chromium.webrtc/waterfall">WebRTC waterfalls</a> in order to test that we can actually acquire hardware webcams on all platforms. We also added a check to just succeed the test when there’s no real webcam on the system since we don’t want it to fail when a dev runs it on a machine without a webcam:  <br /><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">if</span> (!HasWebcamOnSystem())<br />  <span style="color: #0433ff;">return</span>;<br /></pre><br />It would of course be better if Firefox had a similar fake device, but to my knowledge it doesn’t.<br /><br /><h3>Downloading all Code and Components&nbsp;</h3>Now we have all we need to run the test and have it verify something useful. We just have the hard part left: how do we actually download all the resources we need to run this test? Recall that this is actually a three-way integration test between Chrome, Firefox and AppRTC, which require the following:<br /><br /><ul style="line-height: 1.0em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>The AppEngine SDK in order to bring up the local AppRTC instance,&nbsp;</li><li>The AppRTC code itself,&nbsp;</li><li>Chrome (already present in the checkout), and&nbsp;</li><li>Firefox nightly.</li></ul><br />While developing the test, I initially just hand-downloaded these and installed and hard-coded the paths. This is a very bad idea in the long run. Recall that the Chromium infrastructure is comprised of <a href="http://build.chromium.org/">thousands and thousands of machines</a>, and while this test will only run on perhaps 5 at a time due to its webcam requirements, we don’t want manual maintenance work whenever we replace a machine. And for that matter, we definitely don’t want to download a new Firefox by hand every night and put it on the right location on the bots! So how do we automate this? <br /><br /><b>Downloading the AppEngine SDK</b><br />First, let’s start with the easy part. We don’t really care if the AppEngine SDK is up-to-date, so a relatively stale version is fine. We could have the test download it from the <a href="https://developers.google.com/appengine/downloads">authoritative source</a>, but that’s a bad idea for a couple reasons. First, it updates outside our control. Second, there could be anti-robot measures on the page. Third, the download will likely be unreliable and fail the test occasionally. <br /><br />The way we solved this was to upload a copy of the SDK to a <a href="https://cloud.google.com/products/cloud-storage/?utm_source=google&amp;utm_medium=cpc&amp;utm_campaign=cloudstorage-search">Google storage</a> bucket under our control and download it using the <a href="http://dev.chromium.org/developers/how-tos/depottools">depot_tools</a> script <span style="color: #6aa84f; font-family: Courier New, Courier, monospace;"><b>download_from_google_storage.py</b></span>. This is a lot more reliable than an external website and will not download the SDK if we already have the right version on the bot. <br /><br /><b>Downloading the AppRTC Code</b><br />This code is on GitHub. Experience has shown that git clone commands run against GitHub will fail every now and then, and fail the test. We could either write some retry mechanism, but we have found it’s better to simply mirror the git repository in Chromium’s internal mirrors, which are closer to our bots and thereby more reliable from our perspective. The pull is done by a <a href="http://chromegw/viewvc/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/DEPS?revision=262390&amp;view=markup">Chromium DEPS file</a> (which is Chromium’s dependency provisioning framework). <br /><br /><b>Downloading Firefox</b><br />It turns out that Firefox supplies handy libraries for this task. We’re using mozdownload <a href="http://chromegw/viewvc/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/download_firefox_nightly.py?revision=241269&amp;view=markup">in this script</a> in order to download the Firefox nightly build. Unfortunately this <a href="https://code.google.com/p/chromium/issues/detail?id=360516">fails every now and then</a> so we would like to have some retry mechanism, or we could write some mechanism to “mirror” the Firefox nightly build in some location we control.<br /><br /><h3>Putting it Together</h3>With that, we have everything we need to deploy the test. You can see the <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc&amp;q=chrome_webrtc_app&amp;sq=package:chromium&amp;l=297">final code here</a>.  <br /><br />The provisioning code above was put into a separate “<a href="http://chromegw/viewvc/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/">.gclient solution</a>” so that regular Chrome devs and bots are not burdened with downloading hundreds of megs of SDKs and code that they will not use. When this test runs, you will first see a Chrome browser pop up, which will ensure the local apprtc instance is up. Then a Firefox browser will pop up. They will each acquire the fake device and real camera, respectively, and after a short delay the AppRTC call will come up, proving that video interop is working. <br /><br />This is a complicated and expensive test, but we believe it is worth it to keep the main interop case under automation this way, especially as the spec evolves and the browsers are in varying states of implementation. <br /><br />Future Work<br /><br /><ul style="line-height: 1.0em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Also run on Windows/Mac.&nbsp;</li><li>Also test Opera.&nbsp;</li><li>Interop between Chrome/Firefox mobile and desktop browsers.&nbsp;</li><li>Also ensure audio is playing.&nbsp;</li><li>Measure bandwidth stats, video quality, etc.</li></ul><br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/chrome-firefox-webrtc-interop-test-pt-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Chrome &#8211; Firefox WebRTC Interop Test &#8211; Pt 1</title>
		<link>https://googledata.org/google-testing/chrome-firefox-webrtc-interop-test-pt-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=chrome-firefox-webrtc-interop-test-pt-1</link>
		<comments>https://googledata.org/google-testing/chrome-firefox-webrtc-interop-test-pt-1/#comments</comments>
		<pubDate>Tue, 26 Aug 2014 21:05:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=02263ce11a5c1f2094ff18d8d7dd2203</guid>
		<description><![CDATA[<i>by Patrik H&#246;glund </i><br /><br /><a href="http://www.webrtc.org/">WebRTC</a> enables real time peer-to-peer video and voice transfer in the browser, making it possible to build, among other things, a <a href="https://apprtc.appspot.com/">working video chat</a> with a <a href="https://github.com/GoogleChrome/webrtc/tree/master/samples/web/content/apprtc">small amount of Python and JavaScript</a>. As a web standard, it has several unusual properties which makes it hard to test. A regular web standard generally accepts HTML text and yields a bitmap as output (what you see in the browser). For WebRTC, we have real-time RTP media streams on one side being sent to another WebRTC-enabled endpoint. These RTP packets have been jumping across NAT, through firewalls and perhaps through TURN servers to deliver hopefully stutter-free and low latency media. <br /><br />WebRTC is probably the only web standard in which we need to test direct communication between Chrome and other browsers. Remember, WebRTC builds on peer-to-peer technology, which means we talk directly between browsers rather than through a server. Chrome, Firefox and Opera have announced support for WebRTC so far. To test interoperability, we set out to build an automated test to ensure that Chrome and Firefox can get a call up. This article describes how we implemented such a test and the tradeoffs we made along the way.<br /><br /><h3>Calling in WebRTC </h3>Setting up a WebRTC call requires passing  SDP blobs over a signaling connection. These blobs contain information on the capabilities of the endpoint, such as what media formats it supports and what preferences it has (for instance, perhaps the endpoint has VP8 decoding hardware, which means the endpoint will handle VP8 more efficiently than, say, H.264). By sending these blobs the endpoints can agree on what media format they will be sending between themselves and how to traverse the network between them. Once that is done, the browsers will talk directly to each other, and nothing gets sent over the signaling connection.<br /><br /><div><a href="http://4.bp.blogspot.com/-A6zQCufOABs/U_zvIGck2gI/AAAAAAAAAG0/FlqBUQ8h_XY/s1600/image00.png"><img border="0" src="http://4.bp.blogspot.com/-A6zQCufOABs/U_zvIGck2gI/AAAAAAAAAG0/FlqBUQ8h_XY/s1600/image00.png" width="500"></a></div><div><i>Figure 1. Signaling and media connections.</i></div><br />How these blobs are sent is up to the application. Usually the browsers connect to some server which mediates the connection between the browsers, for instance by using a contact list or a room number. The <a href="https://apprtc.appspot.com/">AppRTC reference application</a> uses room numbers to pair up browsers and sends the SDP blobs from the browsers through the AppRTC server.<br /><br /><h3>Test Design</h3>Instead of designing a new signaling solution from scratch, we chose to use the AppRTC application we already had. This has the additional benefit of testing the AppRTC code, which we are also maintaining. We could also have used the small <a href="https://code.google.com/p/chromium/codesearch#chromium/src/third_party/libjingle/libjingle.gyp&#38;q=peerconnection_server&#38;sq=package:chromium&#38;type=cs&#38;l=289">peerconnection_server</a> binary and some JavaScript, which would give us additional flexibility in what to test. We chose to go with AppRTC since it effectively implements the signaling for us, leading to much less test code. <br /><br />We assumed we would be able to get hold of the latest nightly Firefox and be able to launch that with a given URL. For the Chrome side, we assumed we would be running in a browser test, i.e. on a complete Chrome with some test scaffolding around it. For the first sketch of the test, we imagined just connecting the browsers to the live <a href="http://apprtc.appspot.com/">apprtc.appspot.com</a> with some random room number. If the call got established, we would be able to look at the remote video feed on the Chrome side and verify that video was playing (for instance using the <a href="http://googlechrome.github.io/webrtc/samples/web/content/getusermedia-canvas">video+canvas grab trick</a>). Furthermore, we could verify that audio was playing, for instance by using <a href="http://googlechrome.github.io/webrtc/samples/web/content/getusermedia-volume">WebRTC getStats</a> to measure the audio track energy level. <br /><br /><div><a href="http://2.bp.blogspot.com/-KLMJbuz7uGg/U_zvNllz-vI/AAAAAAAAAG8/JJK4j05TQOI/s1600/image01.png"><img border="0" src="http://2.bp.blogspot.com/-KLMJbuz7uGg/U_zvNllz-vI/AAAAAAAAAG8/JJK4j05TQOI/s1600/image01.png" width="500"></a></div><div><i>Figure 2. Basic test design.</i></div><br />However, since we like tests to be <a href="http://googletesting.blogspot.se/2012/10/hermetic-servers.html">hermetic</a>, this isn&#8217;t a good design. I can see several problems. For example, if the network between us and AppRTC is unreliable. Also, what if someone has occupied myroomid? If that were the case, the test would fail and we would be none the wiser. So to make this thing work, we would have to find some way to bring up the AppRTC instance on localhost to make our test hermetic.<br /><br /><h3>Bringing up AppRTC on localhost</h3>AppRTC is a <a href="https://developers.google.com/appengine/">Google App Engine application</a>. As this <a href="https://developers.google.com/appengine/docs/python/gettingstartedpython27/helloworld">hello world example</a> demonstrates, one can test applications locally with<br /><pre>google_appengine/dev_appserver.py apprtc_code/</pre><br />So why not just call this from our test? It turns out we need to solve some complicated problems first, like how to ensure the AppEngine SDK and the AppRTC code is actually available on the executing machine, but we&#8217;ll get to that later. Let&#8217;s assume for now that stuff is just available. We can now write the browser test code to launch the local instance:<br /><pre><span>bool</span> LaunchApprtcInstanceOnLocalhost() <br /><span>// ... Figure out locations of SDK and apprtc code ...</span><br />  CommandLine command_line(CommandLine::NO_PROGRAM);<br />  EXPECT_TRUE(GetPythonCommand(&#38;command_line));<br /><br />  command_line.AppendArgPath(appengine_dev_appserver);<br />  command_line.AppendArgPath(apprtc_dir);<br />  command_line.AppendArg(<span>"--port=9999"</span>);<br />  command_line.AppendArg(<span>"--admin_port=9998"</span>);<br />  command_line.AppendArg(<span>"--skip_sdk_update_check"</span>);<br /><br />  VLOG(1) &#60;&#60; <span>"Running "</span> &#60;&#60; command_line.GetCommandLineString();<br /><span>return</span> base::LaunchProcess(command_line, base::LaunchOptions(),<br />                             &#38;dev_appserver_);<br />}<br /></pre><br />That&#8217;s pretty straightforward <a href="http://googletesting.blogspot.com/#foot1"><sup>[1]</sup></a>.<br /><br /><h3>Figuring out Whether the Local Server is Up&#160;</h3>Then we ran into a very typical test problem. So we have the code to get the server up, and launching the two browsers to connect to <span><b>http://localhost:9999?r=some_room</b></span> is easy. But how do we know when to connect? When I first ran the test, it would work sometimes and sometimes not depending on if the server had time to get up. <br /><br />It&#8217;s tempting in these situations to just add a sleep to give the server time to get up. Don&#8217;t do that. That will result in a test that is flaky and/or slow. In these situations we need to identify what we&#8217;re really waiting for. We could probably monitor the stdout of the <b><span>dev_appserver.py</span></b> and look for some message that says &#8220;Server is up!&#8221; or equivalent. However, we&#8217;re really waiting for the server to be able to serve web pages, and since we have two browsers that are really good at connecting to servers, why not use them? Consider this code.<br /><pre><span>bool</span> LocalApprtcInstanceIsUp() {<br /><span>// Load the admin page and see if we manage to load it right.</span><br />  ui_test_utils::NavigateToURL(browser(), GURL(<span>"localhost:9998"</span>));<br />  content::WebContents* tab_contents =<br />      browser()-&#62;tab_strip_model()-&#62;GetActiveWebContents();<br />  std::<span>string</span> javascript =<br /><span>"window.domAutomationController.send(document.title)"</span>;<br />  std::<span>string</span> result;<br /><span>if</span> (!content::ExecuteScriptAndExtractString(tab_contents, <br />                                              javascript,<br />                                              &#38;result))<br /><span>return</span> <span>false</span>;<br /><br /><span>return</span> result == kTitlePageOfAppEngineAdminPage;<br />}<br /></pre><br />Here we ask Chrome to load the AppEngine admin page for the local server (we set the admin port to <span><b>9998</b></span> earlier, remember?) and ask it what its title is. If that title is &#8220;Instances&#8221;, the admin page has been displayed, and the server must be up. If the server isn&#8217;t up, Chrome will fail to load the page and the title will be something like &#8220;<span><b>localhost:9999</b></span> is not available&#8221;. <br /><br />Then, we can just do this from the test:<br /><pre><span>while</span> (!LocalApprtcInstanceIsUp())<br />  VLOG(1) &#60;&#60; <span>"Waiting for AppRTC to come up..."</span>;<br /></pre><br />If the server never comes up, for whatever reason, the test will just time out in that loop. If it comes up we can safely proceed with the rest of test.<br /><br /><h3>Launching the Browsers&#160;</h3>A browser window launches itself as a part of every Chromium browser test. It&#8217;s also easy for the test to control the command line switches the browser will run under. <br /><br />We have less control over the Firefox browser since it is the &#8220;foreign&#8221; browser in this test, but we can still pass command-line options to it when we invoke the Firefox process. To make this easier, Mozilla provides a Python library called mozrunner. Using that we can set up a <a href="http://chromegw/viewvc/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/run_firefox_webrtc.py?revision=240895&#38;view=markup">launcher python script</a> we can invoke from the test:<br /><pre><span>from</span> mozprofile <span>import</span> profile<br /><span>from</span> mozrunner <span>import</span> runner<br /><br />WEBRTC_PREFERENCES = {<br /><span>'media.navigator.permission.disabled'</span>: True,<br />}<br /><br /><span>def</span> main():<br /><span># Set up flags, handle SIGTERM, etc</span><br /><span># ...</span><br />  firefox_profile = <br />      profile.FirefoxProfile(preferences=WEBRTC_PREFERENCES)<br />  firefox_runner = runner.FirefoxRunner(<br />      profile=firefox_profile, binary=options.binary, <br />      cmdargs=[options.webpage])<br /><br />  firefox_runner.start()</pre><br />Notice that we need to pass special preferences to make Firefox accept the getUserMedia prompt. Otherwise, the test would get stuck on the prompt and we would be unable to set up a call. Alternatively, we could employ some kind of clickbot to click &#8220;Allow&#8221; on the prompt when it pops up, but that is way harder to set up. <br /><br />Without going into too much detail, the code for launching the browsers becomes<br /><pre>GURL room_url = <br />    GURL(base::StringPrintf(<span>"http://localhost:9999?r=room_%d"</span>,<br />                            base::RandInt(0, 65536)));<br />content::WebContents* chrome_tab = <br />    OpenPageAndAcceptUserMedia(room_url);<br />ASSERT_TRUE(LaunchFirefoxWithUrl(room_url));</pre><br />Where LaunchFirefoxWithUrl essentially runs this:<br /><pre>run_firefox_webrtc.py --binary /path/to/firefox --webpage http:<span>//localhost::9999?r=my_room</span></pre><br />Now we can launch the two browsers. Next time we will look at how we actually verify that the call worked, and how we actually download all resources needed by the test in a maintainable and automated manner. Stay tuned!<br /><br /><hr /><sup>1</sup>The explicit ports are because the default ports collided on the bots we were running on, and the --skip_sdk_update_check was because the SDK stopped and asked us something if there was an update. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Patrik Höglund </i><br /><br /><a href="http://www.webrtc.org/">WebRTC</a> enables real time peer-to-peer video and voice transfer in the browser, making it possible to build, among other things, a <a href="https://apprtc.appspot.com/">working video chat</a> with a <a href="https://github.com/GoogleChrome/webrtc/tree/master/samples/web/content/apprtc">small amount of Python and JavaScript</a>. As a web standard, it has several unusual properties which makes it hard to test. A regular web standard generally accepts HTML text and yields a bitmap as output (what you see in the browser). For WebRTC, we have real-time RTP media streams on one side being sent to another WebRTC-enabled endpoint. These RTP packets have been jumping across NAT, through firewalls and perhaps through TURN servers to deliver hopefully stutter-free and low latency media. <br /><br />WebRTC is probably the only web standard in which we need to test direct communication between Chrome and other browsers. Remember, WebRTC builds on peer-to-peer technology, which means we talk directly between browsers rather than through a server. Chrome, Firefox and Opera have announced support for WebRTC so far. To test interoperability, we set out to build an automated test to ensure that Chrome and Firefox can get a call up. This article describes how we implemented such a test and the tradeoffs we made along the way.<br /><br /><h3>Calling in WebRTC </h3>Setting up a WebRTC call requires passing  SDP blobs over a signaling connection. These blobs contain information on the capabilities of the endpoint, such as what media formats it supports and what preferences it has (for instance, perhaps the endpoint has VP8 decoding hardware, which means the endpoint will handle VP8 more efficiently than, say, H.264). By sending these blobs the endpoints can agree on what media format they will be sending between themselves and how to traverse the network between them. Once that is done, the browsers will talk directly to each other, and nothing gets sent over the signaling connection.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-A6zQCufOABs/U_zvIGck2gI/AAAAAAAAAG0/FlqBUQ8h_XY/s1600/image00.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-A6zQCufOABs/U_zvIGck2gI/AAAAAAAAAG0/FlqBUQ8h_XY/s1600/image00.png" width="500" /></a></div><div style="text-align: center;"><i>Figure 1. Signaling and media connections.</i></div><br />How these blobs are sent is up to the application. Usually the browsers connect to some server which mediates the connection between the browsers, for instance by using a contact list or a room number. The <a href="https://apprtc.appspot.com/">AppRTC reference application</a> uses room numbers to pair up browsers and sends the SDP blobs from the browsers through the AppRTC server.<br /><br /><h3>Test Design</h3>Instead of designing a new signaling solution from scratch, we chose to use the AppRTC application we already had. This has the additional benefit of testing the AppRTC code, which we are also maintaining. We could also have used the small <a href="https://code.google.com/p/chromium/codesearch#chromium/src/third_party/libjingle/libjingle.gyp&amp;q=peerconnection_server&amp;sq=package:chromium&amp;type=cs&amp;l=289">peerconnection_server</a> binary and some JavaScript, which would give us additional flexibility in what to test. We chose to go with AppRTC since it effectively implements the signaling for us, leading to much less test code. <br /><br />We assumed we would be able to get hold of the latest nightly Firefox and be able to launch that with a given URL. For the Chrome side, we assumed we would be running in a browser test, i.e. on a complete Chrome with some test scaffolding around it. For the first sketch of the test, we imagined just connecting the browsers to the live <a href="http://apprtc.appspot.com/">apprtc.appspot.com</a> with some random room number. If the call got established, we would be able to look at the remote video feed on the Chrome side and verify that video was playing (for instance using the <a href="http://googlechrome.github.io/webrtc/samples/web/content/getusermedia-canvas">video+canvas grab trick</a>). Furthermore, we could verify that audio was playing, for instance by using <a href="http://googlechrome.github.io/webrtc/samples/web/content/getusermedia-volume">WebRTC getStats</a> to measure the audio track energy level. <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-KLMJbuz7uGg/U_zvNllz-vI/AAAAAAAAAG8/JJK4j05TQOI/s1600/image01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-KLMJbuz7uGg/U_zvNllz-vI/AAAAAAAAAG8/JJK4j05TQOI/s1600/image01.png" width="500" /></a></div><div style="text-align: center;"><i>Figure 2. Basic test design.</i></div><br />However, since we like tests to be <a href="http://googletesting.blogspot.se/2012/10/hermetic-servers.html">hermetic</a>, this isn’t a good design. I can see several problems. For example, if the network between us and AppRTC is unreliable. Also, what if someone has occupied myroomid? If that were the case, the test would fail and we would be none the wiser. So to make this thing work, we would have to find some way to bring up the AppRTC instance on localhost to make our test hermetic.<br /><br /><h3>Bringing up AppRTC on localhost</h3>AppRTC is a <a href="https://developers.google.com/appengine/">Google App Engine application</a>. As this <a href="https://developers.google.com/appengine/docs/python/gettingstartedpython27/helloworld">hello world example</a> demonstrates, one can test applications locally with<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">google_appengine/dev_appserver.py apprtc_code/</pre><br />So why not just call this from our test? It turns out we need to solve some complicated problems first, like how to ensure the AppEngine SDK and the AppRTC code is actually available on the executing machine, but we’ll get to that later. Let’s assume for now that stuff is just available. We can now write the browser test code to launch the local instance:<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">bool</span> LaunchApprtcInstanceOnLocalhost() <br />  <span style="color: #4f8f00;">// ... Figure out locations of SDK and apprtc code ...</span><br />  CommandLine command_line(CommandLine::NO_PROGRAM);<br />  EXPECT_TRUE(GetPythonCommand(&amp;command_line));<br /><br />  command_line.AppendArgPath(appengine_dev_appserver);<br />  command_line.AppendArgPath(apprtc_dir);<br />  command_line.AppendArg(<span style="color: #ff2600;">"--port=9999"</span>);<br />  command_line.AppendArg(<span style="color: #ff2600;">"--admin_port=9998"</span>);<br />  command_line.AppendArg(<span style="color: #ff2600;">"--skip_sdk_update_check"</span>);<br /><br />  VLOG(1) &lt;&lt; <span style="color: #ff2600;">"Running "</span> &lt;&lt; command_line.GetCommandLineString();<br />  <span style="color: #0433ff;">return</span> base::LaunchProcess(command_line, base::LaunchOptions(),<br />                             &amp;dev_appserver_);<br />}<br /></pre><br />That’s pretty straightforward <a href="http://googletesting.blogspot.com/2014/08/chrome-firefox-webrtc-interop-test-pt-1.html#foot1"><sup>[1]</sup></a>.<br /><br /><h3>Figuring out Whether the Local Server is Up&nbsp;</h3>Then we ran into a very typical test problem. So we have the code to get the server up, and launching the two browsers to connect to <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>http://localhost:9999?r=some_room</b></span> is easy. But how do we know when to connect? When I first ran the test, it would work sometimes and sometimes not depending on if the server had time to get up. <br /><br />It’s tempting in these situations to just add a sleep to give the server time to get up. Don’t do that. That will result in a test that is flaky and/or slow. In these situations we need to identify what we’re really waiting for. We could probably monitor the stdout of the <b><span style="color: #38761d; font-family: Courier New, Courier, monospace;">dev_appserver.py</span></b> and look for some message that says “Server is up!” or equivalent. However, we’re really waiting for the server to be able to serve web pages, and since we have two browsers that are really good at connecting to servers, why not use them? Consider this code.<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">bool</span> LocalApprtcInstanceIsUp() {<br />  <span style="color: #4f8f00;">// Load the admin page and see if we manage to load it right.</span><br />  ui_test_utils::NavigateToURL(browser(), GURL(<span style="color: #ff2600;">"localhost:9998"</span>));<br />  content::WebContents* tab_contents =<br />      browser()-&gt;tab_strip_model()-&gt;GetActiveWebContents();<br />  std::<span style="color: #0433ff;">string</span> javascript =<br />      <span style="color: #ff2600;">"window.domAutomationController.send(document.title)"</span>;<br />  std::<span style="color: #0433ff;">string</span> result;<br />  <span style="color: #0433ff;">if</span> (!content::ExecuteScriptAndExtractString(tab_contents, <br />                                              javascript,<br />                                              &amp;result))<br />    <span style="color: #0433ff;">return</span> <span style="color: #0433ff;">false</span>;<br /><br />  <span style="color: #0433ff;">return</span> result == kTitlePageOfAppEngineAdminPage;<br />}<br /></pre><br />Here we ask Chrome to load the AppEngine admin page for the local server (we set the admin port to <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>9998</b></span> earlier, remember?) and ask it what its title is. If that title is “Instances”, the admin page has been displayed, and the server must be up. If the server isn’t up, Chrome will fail to load the page and the title will be something like “<span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>localhost:9999</b></span> is not available”. <br /><br />Then, we can just do this from the test:<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">while</span> (!LocalApprtcInstanceIsUp())<br />  VLOG(1) &lt;&lt; <span style="color: #ff2600;">"Waiting for AppRTC to come up..."</span>;<br /></pre><br />If the server never comes up, for whatever reason, the test will just time out in that loop. If it comes up we can safely proceed with the rest of test.<br /><br /><h3>Launching the Browsers&nbsp;</h3>A browser window launches itself as a part of every Chromium browser test. It’s also easy for the test to control the command line switches the browser will run under. <br /><br />We have less control over the Firefox browser since it is the “foreign” browser in this test, but we can still pass command-line options to it when we invoke the Firefox process. To make this easier, Mozilla provides a Python library called mozrunner. Using that we can set up a <a href="http://chromegw/viewvc/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/run_firefox_webrtc.py?revision=240895&amp;view=markup">launcher python script</a> we can invoke from the test:<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">from</span> mozprofile <span style="color: #0433ff;">import</span> profile<br /><span style="color: #0433ff;">from</span> mozrunner <span style="color: #0433ff;">import</span> runner<br /><br />WEBRTC_PREFERENCES = {<br />    <span style="color: #ff2600;">'media.navigator.permission.disabled'</span>: True,<br />}<br /><br /><span style="color: #0433ff;">def</span> main():<br />  <span style="color: #4f8f00;"># Set up flags, handle SIGTERM, etc</span><br />  <span style="color: #4f8f00;"># ...</span><br />  firefox_profile = <br />      profile.FirefoxProfile(preferences=WEBRTC_PREFERENCES)<br />  firefox_runner = runner.FirefoxRunner(<br />      profile=firefox_profile, binary=options.binary, <br />      cmdargs=[options.webpage])<br /><br />  firefox_runner.start()</pre><br />Notice that we need to pass special preferences to make Firefox accept the getUserMedia prompt. Otherwise, the test would get stuck on the prompt and we would be unable to set up a call. Alternatively, we could employ some kind of clickbot to click “Allow” on the prompt when it pops up, but that is way harder to set up. <br /><br />Without going into too much detail, the code for launching the browsers becomes<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">GURL room_url = <br />    GURL(base::StringPrintf(<span style="color: #ff2600;">"http://localhost:9999?r=room_%d"</span>,<br />                            base::RandInt(0, 65536)));<br />content::WebContents* chrome_tab = <br />    OpenPageAndAcceptUserMedia(room_url);<br />ASSERT_TRUE(LaunchFirefoxWithUrl(room_url));</pre><br />Where LaunchFirefoxWithUrl essentially runs this:<br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">run_firefox_webrtc.py --binary /path/to/firefox --webpage http:<span style="color: #4f8f00;">//localhost::9999?r=my_room</span></pre><br />Now we can launch the two browsers. Next time we will look at how we actually verify that the call worked, and how we actually download all resources needed by the test in a maintainable and automated manner. Stay tuned!<br /><br /><hr /><sup id="foot1">1</sup>The explicit ports are because the default ports collided on the bots we were running on, and the --skip_sdk_update_check was because the SDK stopped and asked us something if there was an update. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/chrome-firefox-webrtc-interop-test-pt-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Web Testing Made Easier: Debug IDs</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-web-testing-made-easier-debug-ids/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-web-testing-made-easier-debug-ids</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-web-testing-made-easier-debug-ids/#comments</comments>
		<pubDate>Tue, 12 Aug 2014 18:53:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=ae4fdc72c921e8e6aef981115504969a</guid>
		<description><![CDATA[<i>by Ruslan Khamitov&#160;</i><br /><i><br /></i><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet (TotT) episode</a>. You can download a <a href="https://docs.google.com/document/d/1zHky363AF_eNVGOgnpD-7ouhjTG7QbYmCmGwbeFKruE/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office.</i><br /><br /><b><span>Adding ID attributes to elements can make it much easier to write tests that interact with the DOM</span></b> (e.g., WebDriver tests). Consider the following DOM with two buttons that differ only by inner text:<br /><table><tbody><tr><td>Save button</td><td>Edit button</td></tr><tr><td><pre>&#60;div class="button"&#62;Save&#60;/div&#62;</pre></td><td><pre>&#60;div class="button"&#62;Edit&#60;/div&#62;</pre></td></tr></tbody></table><br />How would you tell WebDriver to interact with the &#8220;Save&#8221; button in this case?  You have several options.  <b><span>One option is to interact with the button using a CSS selector:</span></b><br /><pre>div.button</pre><br />However, this approach is not sufficient to identify a particular button, and there is no mechanism to filter by text in CSS. <b><span>Another option would be to write an XPath, which is generally fragile and discouraged:</span></b><br /><pre>//div[@class='button' and text()='Save']</pre><br /><b><span>Your best option is to add unique hierarchical IDs</span></b> where each widget is passed a base ID that it prepends to the ID of each of its children. The IDs for each button will be:<br /><pre><b><i>contact-form</i>.save-button<br /><i>contact-form</i>.edit-button</b></pre><br /><b><span>In GWT you can accomplish this by overriding onEnsureDebugId()on your widgets</span></b>. Doing so allows you to create custom logic for applying debug IDs to the sub-elements that make up a custom widget:<br /><pre>@Override <span>protected</span> <span>void</span> <b>onEnsureDebugId</b>(String baseId) {<br /><span>super</span>.<b>onEnsureDebugId</b>(baseId);<br />  saveButton.<b>ensureDebugId</b>(baseId + <span>".save-button"</span>);<br />  editButton.<b>ensureDebugId</b>(baseId + <span>".edit-button"</span>);<br />}</pre><br />Consider another example. <b><span>Let&#8217;s set IDs for repeated UI elements in Angular</span></b> using ng-repeat.  Setting an index can help differentiate between repeated instances of each element:<br /><pre>&#60;tr <b>id="feedback-{{$index}}</b>" class="feedback" ng-repeat="feedback in ctrl.feedbacks" &#62;</pre><br /><b><span>In GWT you can do this with ensureDebugId()</span></b>. Let&#8217;s set an ID for each of the table cells:<br /><pre>@UiField FlexTable table;<br />UIObject.ensureDebugId(table.getCellFormatter().getElement(rowIndex, columnIndex),<br /><b>baseID</b> + <b>colIndex</b> + <span>"-"</span> + <b>rowIndex</b>);</pre><br /><span><b>Take-away: Debug IDs are easy to set and make a huge difference for testing</b></span>. Please add them early.<br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Ruslan Khamitov&nbsp;</i><br /><i><br /></i><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet (TotT) episode</a>. You can download a <a href="https://docs.google.com/document/d/1zHky363AF_eNVGOgnpD-7ouhjTG7QbYmCmGwbeFKruE/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office.</i><br /><br /><b><span style="color: #990000;">Adding ID attributes to elements can make it much easier to write tests that interact with the DOM</span></b> (e.g., WebDriver tests). Consider the following DOM with two buttons that differ only by inner text:<br /><table style="border-collapse: collapse; border: 1px solid black; width: 100%;"><tbody><tr><td style="border: 1px solid black; text-align: center;">Save button</td><td style="border: 1px solid black; text-align: center;">Edit button</td></tr><tr><td style="background: #cfe2f3; border: 1px solid black;"><pre style="background: #cfe2f3; border-color: #7b7b7b; border-style: solid; border-width: 0px; color: black; overflow: auto; padding: 0px 5px;">&lt;div class="button"&gt;Save&lt;/div&gt;</pre></td><td style="background: #cfe2f3; border: 1px solid black;"><pre style="background: #cfe2f3; border-color: #7b7b7b; border-style: solid; border-width: 0px; color: black; overflow: auto; padding: 0px 5px;">&lt;div class="button"&gt;Edit&lt;/div&gt;</pre></td></tr></tbody></table><br />How would you tell WebDriver to interact with the “Save” button in this case?  You have several options.  <b><span style="color: #990000;">One option is to interact with the button using a CSS selector:</span></b><br /><pre style="background: #cfe2f3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">div.button</pre><br />However, this approach is not sufficient to identify a particular button, and there is no mechanism to filter by text in CSS. <b><span style="color: #990000;">Another option would be to write an XPath, which is generally fragile and discouraged:</span></b><br /><pre style="background: #cfe2f3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">//div[@class='button' and text()='Save']</pre><br /><b><span style="color: #990000;">Your best option is to add unique hierarchical IDs</span></b> where each widget is passed a base ID that it prepends to the ID of each of its children. The IDs for each button will be:<br /><pre style="background: #d9ead3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><b><i>contact-form</i>.save-button<br /><i>contact-form</i>.edit-button</b></pre><br /><b><span style="color: #990000;">In GWT you can accomplish this by overriding onEnsureDebugId()on your widgets</span></b>. Doing so allows you to create custom logic for applying debug IDs to the sub-elements that make up a custom widget:<br /><pre style="background: #d9ead3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">@Override <span style="color: #0433ff;">protected</span> <span style="color: #0433ff;">void</span> <b>onEnsureDebugId</b>(String baseId) {<br />  <span style="color: #0433ff;">super</span>.<b>onEnsureDebugId</b>(baseId);<br />  saveButton.<b>ensureDebugId</b>(baseId + <span style="color: #ff2600;">".save-button"</span>);<br />  editButton.<b>ensureDebugId</b>(baseId + <span style="color: #ff2600;">".edit-button"</span>);<br />}</pre><br />Consider another example. <b><span style="color: #990000;">Let’s set IDs for repeated UI elements in Angular</span></b> using ng-repeat.  Setting an index can help differentiate between repeated instances of each element:<br /><pre style="background: #d9ead3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">&lt;tr <b>id="feedback-{{$index}}</b>" class="feedback" ng-repeat="feedback in ctrl.feedbacks" &gt;</pre><br /><b><span style="color: #990000;">In GWT you can do this with ensureDebugId()</span></b>. Let’s set an ID for each of the table cells:<br /><pre style="background: #d9ead3; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">@UiField FlexTable table;<br />UIObject.ensureDebugId(table.getCellFormatter().getElement(rowIndex, columnIndex),<br />    <b>baseID</b> + <b>colIndex</b> + <span style="color: #ff2600;">"-"</span> + <b>rowIndex</b>);</pre><br /><span style="color: #990000;"><b>Take-away: Debug IDs are easy to set and make a huge difference for testing</b></span>. Please add them early.<br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-web-testing-made-easier-debug-ids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Don&#8217;t Put Logic in Tests</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-dont-put-logic-in-tests/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-dont-put-logic-in-tests</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-dont-put-logic-in-tests/#comments</comments>
		<pubDate>Thu, 31 Jul 2014 16:59:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=9eeb5e6826db4d7b82d9a2526e1eb76f</guid>
		<description><![CDATA[<i>by Erik Kuefler </i><br /><i><br /></i><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1f-ISrr6ItyDCJCMaFXOyQBZmekBZwxQ0tZeksoWUZAo/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office.  </i><br /><br /><b><span>Programming languages give us a lot of expressive power.</span></b> Concepts like operators and conditionals are important tools that allow us to write programs that handle a wide range of inputs. But <b><span>this flexibility comes at the cost of increased complexity</span></b>, which makes our programs harder to understand. <br /><br />Unlike production code, <b><span>simplicity is more important than flexibility in tests</span></b>. Most unit tests verify that a single, known input produces a single, known output. <b><span>Tests can avoid complexity by stating their inputs and outputs directly rather than computing them</span></b>. Otherwise it's easy for tests to develop their own bugs.<br /><br />Let's take a look at a simple example. <b><span>Does this test look correct to you? </span></b><br /><br /><pre>@Test <span>public</span> <span>void</span> shouldNavigateToPhotosPage() {<br />  String <b>baseUrl</b> = <span>"http://plus.google.com/"</span>;<br />  Navigator nav = <span>new</span> Navigator(<b>baseUrl</b>);<br />  nav.goToPhotosPage();<br />  assertEquals(<b>baseUrl</b> + <span><b>"/u/0/photos"</b></span>, nav.getCurrentUrl());<br />}</pre><br />The author is trying to avoid duplication by storing a shared prefix in a variable. Performing a single string concatenation doesn't seem too bad, but <b><span>what happens if we simplify the test by inlining the variable? </span></b><br /><br /><pre>@Test <span>public</span> <span>void</span> shouldNavigateToPhotosPage() {<br />  Navigator nav = <span>new</span> Navigator(<span>"http://plus.google.com/"</span>);<br />  nav.goToPhotosPage();<br />  assertEquals(<span>"<b>http://plus.google.com//u/0/photos</b>"</span>, nav.getCurrentUrl()); <span>// <b>Oops!</b></span><br />}</pre><br /><b><span>After eliminating the unnecessary computation from the test, the bug is obvious</span></b>&#8212;we're expecting two slashes in the URL! This test will either fail or (even worse) incorrectly pass if the production code has the same bug. We never would have written this if we stated our inputs and outputs directly instead of trying to compute them. And this is a very simple example&#8212;<span><b>when a test adds more operators or includes loops and conditionals, it becomes increasingly difficult to be confident that it is correct. </b></span><br /><br />Another way of saying this is that, <b><span>whereas production code describes a general strategy for computing outputs given inputs, tests are concrete examples of input/output pairs</span></b> (where output might include side effects like verifying interactions with other classes). It's usually easy to tell whether an input/output pair is correct or not, even if the logic required to compute it is very complex. For instance, it's hard to picture the exact DOM that would be created by a Javascript function for a given server response. So the ideal test for such a function would just compare against a string containing the expected output HTML. <br /><br /><b><span>When tests do need their own logic, such logic should often be moved out of the test bodies and into utilities and helper functions</span></b>. Since such helpers can get quite complex, it's usually a good idea for any nontrivial test utility to have its own tests.<br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Erik Kuefler </i><br /><i><br /></i><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1f-ISrr6ItyDCJCMaFXOyQBZmekBZwxQ0tZeksoWUZAo/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office.  </i><br /><br /><b><span style="color: #990000;">Programming languages give us a lot of expressive power.</span></b> Concepts like operators and conditionals are important tools that allow us to write programs that handle a wide range of inputs. But <b><span style="color: #990000;">this flexibility comes at the cost of increased complexity</span></b>, which makes our programs harder to understand. <br /><br />Unlike production code, <b><span style="color: #990000;">simplicity is more important than flexibility in tests</span></b>. Most unit tests verify that a single, known input produces a single, known output. <b><span style="color: #990000;">Tests can avoid complexity by stating their inputs and outputs directly rather than computing them</span></b>. Otherwise it's easy for tests to develop their own bugs.<br /><br />Let's take a look at a simple example. <b><span style="color: #990000;">Does this test look correct to you? </span></b><br /><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">@Test <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> shouldNavigateToPhotosPage() {<br />  String <b>baseUrl</b> = <span style="color: #ff2600;">"http://plus.google.com/"</span>;<br />  Navigator nav = <span style="color: #0433ff;">new</span> Navigator(<b>baseUrl</b>);<br />  nav.goToPhotosPage();<br />  assertEquals(<b>baseUrl</b> + <span style="color: #ff2600;"><b>"/u/0/photos"</b></span>, nav.getCurrentUrl());<br />}</pre><br />The author is trying to avoid duplication by storing a shared prefix in a variable. Performing a single string concatenation doesn't seem too bad, but <b><span style="color: #990000;">what happens if we simplify the test by inlining the variable? </span></b><br /><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">@Test <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> shouldNavigateToPhotosPage() {<br />  Navigator nav = <span style="color: #0433ff;">new</span> Navigator(<span style="color: #ff2600;">"http://plus.google.com/"</span>);<br />  nav.goToPhotosPage();<br />  assertEquals(<span style="color: #ff2600;">"<b>http://plus.google.com//u/0/photos</b>"</span>, nav.getCurrentUrl()); <span style="color: #4f8f00;">// <b>Oops!</b></span><br />}</pre><br /><b><span style="color: #990000;">After eliminating the unnecessary computation from the test, the bug is obvious</span></b>—we're expecting two slashes in the URL! This test will either fail or (even worse) incorrectly pass if the production code has the same bug. We never would have written this if we stated our inputs and outputs directly instead of trying to compute them. And this is a very simple example—<span style="color: #990000;"><b>when a test adds more operators or includes loops and conditionals, it becomes increasingly difficult to be confident that it is correct. </b></span><br /><br />Another way of saying this is that, <b><span style="color: #990000;">whereas production code describes a general strategy for computing outputs given inputs, tests are concrete examples of input/output pairs</span></b> (where output might include side effects like verifying interactions with other classes). It's usually easy to tell whether an input/output pair is correct or not, even if the logic required to compute it is very complex. For instance, it's hard to picture the exact DOM that would be created by a Javascript function for a given server response. So the ideal test for such a function would just compare against a string containing the expected output HTML. <br /><br /><b><span style="color: #990000;">When tests do need their own logic, such logic should often be moved out of the test bodies and into utilities and helper functions</span></b>. Since such helpers can get quite complex, it's usually a good idea for any nontrivial test utility to have its own tests.<br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-dont-put-logic-in-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>The Deadline to Sign up for GTAC 2014 is Jul 28</title>
		<link>https://googledata.org/google-testing/the-deadline-to-sign-up-for-gtac-2014-is-jul-28/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-deadline-to-sign-up-for-gtac-2014-is-jul-28</link>
		<comments>https://googledata.org/google-testing/the-deadline-to-sign-up-for-gtac-2014-is-jul-28/#comments</comments>
		<pubDate>Wed, 23 Jul 2014 00:53:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=54605ca45a93ef96fb4fe92e634cc9be</guid>
		<description><![CDATA[<i>Posted by Anthony Vallone on behalf of the GTAC Committee </i><br /><br />The deadline to sign up for GTAC 2014 is next Monday, July 28th, 2014. There is a great deal of interest to both attend and speak, and we&#8217;ve received many outstanding proposals. However, it&#8217;s not too late to add yours for consideration. If you would like to speak or attend, be sure to <a href="https://docs.google.com/a/google.com/forms/d/1HVm6KcFBdQAbhX_uh6LEjVYI1ZCCr-L9t7ocbtvLIMU/viewform">complete the form</a> by Monday.  <br /><br />We will be making regular updates to our site over the next several weeks, and you can find conference details there:<br />&#160; <a href="http://developers.google.com/gtac">developers.google.com/gtac</a><br /><br />For those that have already signed up to attend or speak, we will contact you directly in mid August. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>Posted by Anthony Vallone on behalf of the GTAC Committee </i><br /><br />The deadline to sign up for GTAC 2014 is next Monday, July 28th, 2014. There is a great deal of interest to both attend and speak, and we’ve received many outstanding proposals. However, it’s not too late to add yours for consideration. If you would like to speak or attend, be sure to <a href="https://docs.google.com/a/google.com/forms/d/1HVm6KcFBdQAbhX_uh6LEjVYI1ZCCr-L9t7ocbtvLIMU/viewform">complete the form</a> by Monday.  <br /><br />We will be making regular updates to our site over the next several weeks, and you can find conference details there:<br />&nbsp; <a href="http://developers.google.com/gtac">developers.google.com/gtac</a><br /><br />For those that have already signed up to attend or speak, we will contact you directly in mid August. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/the-deadline-to-sign-up-for-gtac-2014-is-jul-28/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Measuring Coverage at Google</title>
		<link>https://googledata.org/google-testing/measuring-coverage-at-google/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=measuring-coverage-at-google</link>
		<comments>https://googledata.org/google-testing/measuring-coverage-at-google/#comments</comments>
		<pubDate>Mon, 14 Jul 2014 19:42:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=41e09e054a805e409acdc753a8dafe10</guid>
		<description><![CDATA[<i>By Marko Ivankovi&#263;, Google Z&#252;rich</i><br /><br /><h3>Introduction</h3><br /><a href="http://en.wikipedia.org/wiki/Code_coverage">Code coverage</a> is a very interesting metric, covered by a <a href="http://scholar.google.com/scholar?q=%22code+coverage%22">large body of research</a> that reaches somewhat contradictory results. Some people think it is an extremely useful metric and that a certain percentage of coverage should be enforced on all code. Some think it is a useful tool to identify areas that need more testing but don&#8217;t necessarily trust that covered code is truly well tested. Others yet think that measuring coverage is actively harmful because it provides a false sense of security. <br /><br />Our team&#8217;s mission was to collect coverage related data then develop and champion code coverage practices across Google. We designed an opt-in system where engineers could enable two different types of coverage measurements for their projects: daily and per-commit. With daily coverage, we run all tests for their project, where as with per-commit coverage we run only the tests affected by the commit. The two measurements are independent and many projects opted into both. <br /><br />While we did experiment with branch, function and statement coverage, we ended up focusing mostly on statement coverage because of its relative simplicity and ease of visualization.<br /><br /><h3>How we measured </h3><br />Our job was made significantly easier by the wonderful <a href="http://google-engtools.blogspot.ch/2011/08/build-in-cloud-how-build-system-works.html">Google build system</a> whose parallelism and flexibility allowed us to simply scale our measurements to Google scale. The build system had integrated various language-specific open source coverage measurement tools like <a href="https://gcc.gnu.org/onlinedocs/gcc/Gcov.html">Gcov</a> (C++), <a href="http://emma.sourceforge.net/">Emma</a> / <a href="http://www.eclemma.org/jacoco/">JaCoCo</a> (Java) and <a href="https://pypi.python.org/pypi/coverage/3.7.1">Coverage.py</a> (Python), and we provided a central system where teams could sign up for coverage measurement.<br /><br />For daily whole project coverage measurements, each team was provided with a simple cronjob that would run all tests across the project&#8217;s codebase. The results of these runs were available to the teams in a centralized dashboard that displays charts showing coverage over time and allows daily / weekly / quarterly / yearly aggregations and per-language slicing. On this dashboard teams can also compare their project (or projects) with any other project, or Google as a whole. <br /><br />For per-commit measurement, we hook into the Google code review process (<a href="http://googletesting.blogspot.ch/2014/01/the-google-test-and-development_21.html">briefly explained in this article</a>) and display the data visually to both the commit author and the reviewers. We display the data on two levels: color coded lines right next to the color coded diff and a total aggregate number for the entire commit.  <br /><br /><div><a href="http://1.bp.blogspot.com/-cWVgcOaZRyA/U8QuI4RynII/AAAAAAAAAGc/nAbVkwYjTBg/s1600/image01.png"><img border="0" src="http://1.bp.blogspot.com/-cWVgcOaZRyA/U8QuI4RynII/AAAAAAAAAGc/nAbVkwYjTBg/s1600/image01.png" height="145" width="400"></a></div><br />Displayed above is a screenshot of the code review tool. The green line coloring is the standard diff coloring for added lines. The orange and lighter green coloring on the line <b>numbers</b> is the coverage information. We use light green for covered lines, orange for non-covered lines and white for non-instrumented lines. <br /><br />It&#8217;s important to note that we surface the coverage information <b>before</b> the commit is submitted to the codebase, because this is the time when engineers are most likely to be interested in improving it.<br /><br /><h3>Results</h3><br />One of the main benefits of working at Google is the scale at which we operate. We have been running the coverage measurement system for some time now and we have collected data for more than 650 different projects, spanning 100,000+ commits. We have a significant amount of data for C++, Java, Python, Go and JavaScript code. <br /><br />I am happy to say that we can share some preliminary results with you today: <br /><br /><div><a href="http://4.bp.blogspot.com/-FBwOXyefWMw/U8QuPBBZa2I/AAAAAAAAAGk/lvzZNmyB_bI/s1600/image00.png"><img border="0" src="http://4.bp.blogspot.com/-FBwOXyefWMw/U8QuPBBZa2I/AAAAAAAAAGk/lvzZNmyB_bI/s1600/image00.png" height="262" width="640"></a></div><br />The chart above is the histogram of average values of measured absolute coverage across Google. The median (50th percentile) code coverage is 78%, the 75th percentile 85% and 90th percentile 90%. We believe that these numbers represent a very healthy codebase. <br /><br />We have also found it very interesting that there are significant differences between languages:  <br /><br /><table><tbody><tr><td>C++</td><td>Java</td><td>Go</td><td>JavaScript</td><td>Python</td></tr><tr><td>56.6%</td><td>61.2%</td><td>63.0%</td><td>76.9%</td><td>84.2%</td></tr></tbody></table><br /><br />The table above shows the total coverage of all analyzed code for each language, averaged over the past quarter. We believe that the large difference is due to structural, paradigm and best practice differences between languages and the more precise ability to measure coverage in certain languages. <br /><br />Note that these numbers should not be interpreted as guidelines for a particular language, the aggregation method used is too simple for that. Instead this finding is simply a data point for any future research that analyzes samples from a single programming language. <br /><br />The feedback from our fellow engineers was overwhelmingly positive. The most loved feature was surfacing the coverage information during code review time. This early surfacing of coverage had a statistically significant impact: our initial analysis suggests that it increased coverage by 10% (averaged across all commits).<br /><br /><h3>Future work</h3><br />We are aware that there are a few problems with the dataset we collected. In particular, the individual tools we use to measure coverage are not perfect. Large integration tests, end to end tests and UI tests are difficult to instrument, so large parts of code exercised by such tests can be misreported as non-covered. <br /><br />We are working on improving the tools, but also analyzing the impact of unit tests, integration tests and other types of tests individually.  <br /><br />In addition to languages, we will also investigate other factors that might influence coverage, such as platforms and frameworks, to allow all future research to account for their effect. <br /><br />We will be publishing more of our findings in the future, so stay tuned. <br /><br />And if this sounds like something you would like to work on, why not apply on our <a href="http://goo.gl/tFRejX">job site</a>? <br /><br />]]></description>
				<content:encoded><![CDATA[<i>By Marko Ivanković, Google Zürich</i><br /><br><h3>Introduction</h3><br><a href="http://en.wikipedia.org/wiki/Code_coverage">Code coverage</a> is a very interesting metric, covered by a <a href="http://scholar.google.com/scholar?q=%22code+coverage%22">large body of research</a> that reaches somewhat contradictory results. Some people think it is an extremely useful metric and that a certain percentage of coverage should be enforced on all code. Some think it is a useful tool to identify areas that need more testing but don’t necessarily trust that covered code is truly well tested. Others yet think that measuring coverage is actively harmful because it provides a false sense of security. <br /><br />Our team’s mission was to collect coverage related data then develop and champion code coverage practices across Google. We designed an opt-in system where engineers could enable two different types of coverage measurements for their projects: daily and per-commit. With daily coverage, we run all tests for their project, where as with per-commit coverage we run only the tests affected by the commit. The two measurements are independent and many projects opted into both. <br /><br />While we did experiment with branch, function and statement coverage, we ended up focusing mostly on statement coverage because of its relative simplicity and ease of visualization.<br /><br><h3>How we measured </h3><br />Our job was made significantly easier by the wonderful <a href="http://google-engtools.blogspot.ch/2011/08/build-in-cloud-how-build-system-works.html">Google build system</a> whose parallelism and flexibility allowed us to simply scale our measurements to Google scale. The build system had integrated various language-specific open source coverage measurement tools like <a href="https://gcc.gnu.org/onlinedocs/gcc/Gcov.html">Gcov</a> (C++), <a href="http://emma.sourceforge.net/">Emma</a> / <a href="http://www.eclemma.org/jacoco/">JaCoCo</a> (Java) and <a href="https://pypi.python.org/pypi/coverage/3.7.1">Coverage.py</a> (Python), and we provided a central system where teams could sign up for coverage measurement.<br /><br />For daily whole project coverage measurements, each team was provided with a simple cronjob that would run all tests across the project’s codebase. The results of these runs were available to the teams in a centralized dashboard that displays charts showing coverage over time and allows daily / weekly / quarterly / yearly aggregations and per-language slicing. On this dashboard teams can also compare their project (or projects) with any other project, or Google as a whole. <br /><br />For per-commit measurement, we hook into the Google code review process (<a href="http://googletesting.blogspot.ch/2014/01/the-google-test-and-development_21.html">briefly explained in this article</a>) and display the data visually to both the commit author and the reviewers. We display the data on two levels: color coded lines right next to the color coded diff and a total aggregate number for the entire commit.  <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-cWVgcOaZRyA/U8QuI4RynII/AAAAAAAAAGc/nAbVkwYjTBg/s1600/image01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-cWVgcOaZRyA/U8QuI4RynII/AAAAAAAAAGc/nAbVkwYjTBg/s1600/image01.png" height="145" width="400" /></a></div><br />Displayed above is a screenshot of the code review tool. The green line coloring is the standard diff coloring for added lines. The orange and lighter green coloring on the line <b>numbers</b> is the coverage information. We use light green for covered lines, orange for non-covered lines and white for non-instrumented lines. <br /><br />It’s important to note that we surface the coverage information <b>before</b> the commit is submitted to the codebase, because this is the time when engineers are most likely to be interested in improving it.<br /><br><h3>Results</h3><br />One of the main benefits of working at Google is the scale at which we operate. We have been running the coverage measurement system for some time now and we have collected data for more than 650 different projects, spanning 100,000+ commits. We have a significant amount of data for C++, Java, Python, Go and JavaScript code. <br /><br />I am happy to say that we can share some preliminary results with you today: <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-FBwOXyefWMw/U8QuPBBZa2I/AAAAAAAAAGk/lvzZNmyB_bI/s1600/image00.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-FBwOXyefWMw/U8QuPBBZa2I/AAAAAAAAAGk/lvzZNmyB_bI/s1600/image00.png" height="262" width="640" /></a></div><br />The chart above is the histogram of average values of measured absolute coverage across Google. The median (50th percentile) code coverage is 78%, the 75th percentile 85% and 90th percentile 90%. We believe that these numbers represent a very healthy codebase. <br /><br />We have also found it very interesting that there are significant differences between languages:  <br /><br /><table style="border-collapse: collapse; border: 1px solid black; width: 100%;"><tbody><tr><td style="border: 1px solid black; padding: 5px;">C++</td><td style="border: 1px solid black; padding: 5px;">Java</td><td style="border: 1px solid black; padding: 5px;">Go</td><td style="border: 1px solid black; padding: 5px;">JavaScript</td><td style="border: 1px solid black; padding: 5px;">Python</td></tr><tr><td style="border: 1px solid black; padding: 5px;">56.6%</td><td style="border: 1px solid black; padding: 5px;">61.2%</td><td style="border: 1px solid black; padding: 5px;">63.0%</td><td style="border: 1px solid black; padding: 5px;">76.9%</td><td style="border: 1px solid black; padding: 5px;">84.2%</td></tr></tbody></table><br /><br />The table above shows the total coverage of all analyzed code for each language, averaged over the past quarter. We believe that the large difference is due to structural, paradigm and best practice differences between languages and the more precise ability to measure coverage in certain languages. <br /><br />Note that these numbers should not be interpreted as guidelines for a particular language, the aggregation method used is too simple for that. Instead this finding is simply a data point for any future research that analyzes samples from a single programming language. <br /><br />The feedback from our fellow engineers was overwhelmingly positive. The most loved feature was surfacing the coverage information during code review time. This early surfacing of coverage had a statistically significant impact: our initial analysis suggests that it increased coverage by 10% (averaged across all commits).<br /><br><h3>Future work</h3><br />We are aware that there are a few problems with the dataset we collected. In particular, the individual tools we use to measure coverage are not perfect. Large integration tests, end to end tests and UI tests are difficult to instrument, so large parts of code exercised by such tests can be misreported as non-covered. <br /><br />We are working on improving the tools, but also analyzing the impact of unit tests, integration tests and other types of tests individually.  <br /><br />In addition to languages, we will also investigate other factors that might influence coverage, such as platforms and frameworks, to allow all future research to account for their effect. <br /><br />We will be publishing more of our findings in the future, so stay tuned. <br /><br />And if this sounds like something you would like to work on, why not apply on our <a href="http://goo.gl/tFRejX">job site</a>? <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/measuring-coverage-at-google/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>ThreadSanitizer: Slaughtering Data Races</title>
		<link>https://googledata.org/google-testing/threadsanitizer-slaughtering-data-races/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=threadsanitizer-slaughtering-data-races</link>
		<comments>https://googledata.org/google-testing/threadsanitizer-slaughtering-data-races/#comments</comments>
		<pubDate>Mon, 30 Jun 2014 21:30:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=dff169cd4b36bc049672bd674b44b0e0</guid>
		<description><![CDATA[by Dmitry Vyukov, Synchronization Lookout, Google, MoscowHello, I work in the Dynamic Testing Tools team at Google. Our team develops tools like AddressSanitizer, MemorySanitizer and ThreadSanitizer which find various kinds of bugs. In this blog post I...]]></description>
				<content:encoded><![CDATA[<i>by Dmitry Vyukov, Synchronization Lookout, Google, Moscow</i><br /><br />Hello, <br /><br />I work in the Dynamic Testing Tools team at Google. Our team develops tools like <a href="http://address-sanitizer.googlecode.com/">AddressSanitizer</a>, <a href="http://memory-sanitizer.googlecode.com/">MemorySanitizer</a> and <a href="http://thread-sanitizer.googlecode.com/">ThreadSanitizer</a> which find various kinds of bugs. In this blog post I want to tell you about ThreadSanitizer, a fast data race detector for C++ and Go programs. <br /><br />First of all, what is a <a href="http://en.wikipedia.org/wiki/Race_condition">data race</a>? A data race occurs when two threads access the same variable concurrently, and at least one of the accesses attempts is a write. Most programming languages provide very weak guarantees, or no guarantees at all, for programs with data races. For example, in C++ absolutely any data race renders the behavior of the whole program as completely undefined (yes, it can suddenly format the hard drive). Data races are common in concurrent programs, and they are notoriously hard to debug and localize. A typical manifestation of a data race is when a program occasionally crashes with obscure symptoms, the symptoms are different each time and do not point to any particular place in the source code. Such bugs can take several months of debugging without particular success, since typical debugging techniques do not work. Fortunately, ThreadSanitizer can catch most data races in the blink of an eye. See Chromium <a href="https://code.google.com/p/chromium/issues/detail?id=15577">issue 15577</a> for an example of such a data race and <a href="https://code.google.com/p/chromium/issues/detail?id=18488">issue 18488</a> for the resolution. <br /><br />Due to the complex nature of bugs caught by ThreadSanitizer, we don't suggest waiting until product release validation to use the tool. For example, in Google, we've made our tools easily accessible to programmers during development, so that anyone can use the tool for testing if they suspect that new code might introduce a race. For both Chromium and Google internal server codebase, we run unit tests that use the tool continuously. This catches many regressions instantly. The Chromium project has recently started using ThreadSanitizer on <a href="http://blog.chromium.org/2012/04/fuzzing-for-security.html">ClusterFuzz</a>, a large scale fuzzing system. Finally, some teams also set up periodic end-to-end testing with ThreadSanitizer under a realistic workload, which proves to be extremely valuable. When races are found by the tool, our team has zero tolerance for races and does not consider any race to be benign, as even the most benign races can lead to <a href="https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong">memory corruption</a>. <br /><br />Our tools are <a href="http://en.wikipedia.org/wiki/Dynamic_program_analysis">dynamic</a> (as opposed to <a href="http://en.wikipedia.org/wiki/Static_analysis_tool">static tools</a>). This means that they do not merely "look" at the code and try to surmise where bugs can be; instead they they <a href="http://en.wikipedia.org/wiki/Instrumentation_(computer_programming)">instrument</a> the binary at build time and then analyze dynamic behavior of the program to catch it red-handed. This approach has its pros and cons. On one hand, the tool does not have any false positives, thus it does not bother a developer with something that is not a bug. On the other hand, in order to catch a bug, the test must expose a bug -- the racing data access attempts must be executed in different threads. This requires writing good multi-threaded tests and makes end-to-end testing especially effective. <br /><br />As a bonus, ThreadSanitizer finds some other types of bugs: thread leaks, deadlocks, incorrect uses of mutexes, malloc calls in signal handlers, and <a href="https://code.google.com/p/thread-sanitizer/wiki/DetectableBugs">more</a>. It also natively understands atomic operations and thus can find bugs in <a href="http://en.wikipedia.org/wiki/Lock-free">lock-free</a> algorithms (see e.g. <a href="https://code.google.com/p/chromium/issues/detail?id=330528">this bug</a> in the V8 concurrent garbage collector). <br /><br />The tool is supported by both Clang and GCC compilers (only on Linux/Intel64). Using it is very simple: you just need to add a <b><span style="color: #38761d; font-family: Courier New, Courier, monospace;">-fsanitize=thread</span></b> flag during compilation and linking. For Go programs, you simply need to add a <b><span style="color: #38761d; font-family: Courier New, Courier, monospace;">-race flag</span></b> to the go tool (supported on Linux, Mac and Windows). <br /><br />Interestingly, after integrating the tool into compilers, we've found some bugs in the compilers themselves. For example, LLVM was <a href="http://llvm.org/bugs/show_bug.cgi?id=13691">illegally widening stores</a>, which can introduce very harmful data races into otherwise correct programs. And GCC was injecting <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48076">unsafe code</a> for initialization of function static variables. Among our other trophies are more than <a href="https://code.google.com/p/thread-sanitizer/wiki/FoundBugs">a thousand bugs</a> in Chromium, Firefox, the Go standard library, WebRTC, OpenSSL, and of course in our internal projects. <br /><br />So what are you waiting for? You know what to do! ]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/threadsanitizer-slaughtering-data-races/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>GTAC 2014: Call for Proposals &amp; Attendance</title>
		<link>https://googledata.org/google-testing/gtac-2014-call-for-proposals-attendance/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gtac-2014-call-for-proposals-attendance</link>
		<comments>https://googledata.org/google-testing/gtac-2014-call-for-proposals-attendance/#comments</comments>
		<pubDate>Mon, 16 Jun 2014 21:57:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=21adc4a3d5d1734d009da7814ceaa55c</guid>
		<description><![CDATA[<i>Posted by Anthony Vallone on behalf of the GTAC Committee</i><br /><br />The application process is now open for presentation proposals and attendance for GTAC (Google Test Automation Conference) (<a href="http://googletesting.blogspot.com/2014/06/gtac-2014-coming-to-seattlekirkland-in.html">see initial announcement</a>) to be held at the <a href="http://www.google.com/about/careers/locations/seattle-kirkland/">Google Kirkland office (near Seattle, WA)</a> on October 28 - 29th, 2014.<br /><br />GTAC will be streamed live on YouTube again this year, so even if you can&#8217;t attend, you&#8217;ll be able to watch the conference from your computer.<br /><br /><b>Speakers</b><br />Presentations are targeted at student, academic, and experienced engineers working on test automation. Full presentations and lightning talks are 45 minutes and 15 minutes respectively. Speakers should be prepared for a question and answer session following their presentation.<br /><br /><b>Application</b><br />For presentation proposals and/or attendance, <a href="https://docs.google.com/forms/d/1HVm6KcFBdQAbhX_uh6LEjVYI1ZCCr-L9t7ocbtvLIMU/viewform?usp=send_form">complete this form</a>. We will be selecting about 300 applicants for the event.<br /><br /><b>Deadline</b><br />The due date for both presentation and attendance applications is July 28, 2014.<br /><br /><b>Fees</b><br />There are no registration fees, and we will send out detailed registration instructions to each invited applicant. Meals will be provided, but speakers and attendees must arrange and pay for their own travel and accommodations. <br /><br /><b><span>Update</span> : </b>Our <a href="https://developers.google.com/google-test-automation-conference/2014/contact">contact</a> email was bouncing - this is now fixed.<br /><br /><br /><div><a href="http://2.bp.blogspot.com/-ho3a6DukQw4/U59Eb4GsfdI/AAAAAAAAAGM/8jPcyc3_SHQ/s1600/GTAC+2014+logo.png"><img border="0" src="http://2.bp.blogspot.com/-ho3a6DukQw4/U59Eb4GsfdI/AAAAAAAAAGM/8jPcyc3_SHQ/s1600/GTAC+2014+logo.png" height="200" width="200"></a></div><br />]]></description>
				<content:encoded><![CDATA[<i>Posted by Anthony Vallone on behalf of the GTAC Committee</i><br /><br />The application process is now open for presentation proposals and attendance for GTAC (Google Test Automation Conference) (<a href="http://googletesting.blogspot.com/2014/06/gtac-2014-coming-to-seattlekirkland-in.html">see initial announcement</a>) to be held at the <a href="http://www.google.com/about/careers/locations/seattle-kirkland/">Google Kirkland office (near Seattle, WA)</a> on October 28 - 29th, 2014.<br /><br />GTAC will be streamed live on YouTube again this year, so even if you can’t attend, you’ll be able to watch the conference from your computer.<br /><br /><b>Speakers</b><br />Presentations are targeted at student, academic, and experienced engineers working on test automation. Full presentations and lightning talks are 45 minutes and 15 minutes respectively. Speakers should be prepared for a question and answer session following their presentation.<br /><br /><b>Application</b><br />For presentation proposals and/or attendance, <a href="https://docs.google.com/forms/d/1HVm6KcFBdQAbhX_uh6LEjVYI1ZCCr-L9t7ocbtvLIMU/viewform?usp=send_form">complete this form</a>. We will be selecting about 300 applicants for the event.<br /><br /><b>Deadline</b><br />The due date for both presentation and attendance applications is July 28, 2014.<br /><br /><b>Fees</b><br />There are no registration fees, and we will send out detailed registration instructions to each invited applicant. Meals will be provided, but speakers and attendees must arrange and pay for their own travel and accommodations. <br /><br /><b><span style="color: red;">Update</span> : </b>Our <a href="https://developers.google.com/google-test-automation-conference/2014/contact">contact</a> email was bouncing - this is now fixed.<br /><br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-ho3a6DukQw4/U59Eb4GsfdI/AAAAAAAAAGM/8jPcyc3_SHQ/s1600/GTAC+2014+logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-ho3a6DukQw4/U59Eb4GsfdI/AAAAAAAAAGM/8jPcyc3_SHQ/s1600/GTAC+2014+logo.png" height="200" width="200" /></a></div><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/gtac-2014-call-for-proposals-attendance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>GTAC 2014 Coming to Seattle/Kirkland in October</title>
		<link>https://googledata.org/google-testing/gtac-2014-coming-to-seattlekirkland-in-october/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gtac-2014-coming-to-seattlekirkland-in-october</link>
		<comments>https://googledata.org/google-testing/gtac-2014-coming-to-seattlekirkland-in-october/#comments</comments>
		<pubDate>Wed, 04 Jun 2014 19:21:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=41f5406d799a055857d2c076676ee25b</guid>
		<description><![CDATA[<i>Posted by Anthony Vallone on behalf of the GTAC Committee</i><br /><br />If you're looking for a place to discuss the latest innovations in test automation, then charge your tablets and pack your <a href="http://en.wikipedia.org/wiki/Wellington_boot">gumboots</a> - the  eighth <a href="https://developers.google.com/gtac/">GTAC</a> (Google Test Automation Conference) will be held on October 28-29, 2014 at Google Kirkland! The Kirkland office is part of the <a href="http://www.google.com/about/careers/locations/seattle-kirkland/">Seattle/Kirkland campus</a> in beautiful Washington state. This campus forms our third largest engineering office in the USA.<br /><br /><div><a href="http://3.bp.blogspot.com/-6pFux0LhOmA/U49xL6rnkrI/AAAAAAAAAF8/E8uecMVaSio/s1600/GTAC+2014+logo.png"><img border="0" src="http://3.bp.blogspot.com/-6pFux0LhOmA/U49xL6rnkrI/AAAAAAAAAF8/E8uecMVaSio/s1600/GTAC+2014+logo.png" height="200" width="200"></a></div><br /><br />GTAC is a periodic conference hosted by Google, bringing together engineers from industry and academia to discuss advances in test automation and the test engineering computer science field. It&#8217;s a great opportunity to present, learn, and challenge modern testing technologies and strategies.  <br /><br />You can browse the presentation abstracts, slides, and videos from last year on the <a href="https://developers.google.com/google-test-automation-conference/2013/">GTAC 2013 page</a>. <br /><br />Stay tuned to this blog and the GTAC website for application information and opportunities to present at GTAC. Subscribing to this blog is the best way to get notified. We're looking forward to seeing you there!  <br /><br />]]></description>
				<content:encoded><![CDATA[<i>Posted by Anthony Vallone on behalf of the GTAC Committee</i><br /><br />If you're looking for a place to discuss the latest innovations in test automation, then charge your tablets and pack your <a href="http://en.wikipedia.org/wiki/Wellington_boot">gumboots</a> - the  eighth <a href="https://developers.google.com/gtac/">GTAC</a> (Google Test Automation Conference) will be held on October 28-29, 2014 at Google Kirkland! The Kirkland office is part of the <a href="http://www.google.com/about/careers/locations/seattle-kirkland/">Seattle/Kirkland campus</a> in beautiful Washington state. This campus forms our third largest engineering office in the USA.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-6pFux0LhOmA/U49xL6rnkrI/AAAAAAAAAF8/E8uecMVaSio/s1600/GTAC+2014+logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-6pFux0LhOmA/U49xL6rnkrI/AAAAAAAAAF8/E8uecMVaSio/s1600/GTAC+2014+logo.png" height="200" width="200" /></a></div><br /><br />GTAC is a periodic conference hosted by Google, bringing together engineers from industry and academia to discuss advances in test automation and the test engineering computer science field. It’s a great opportunity to present, learn, and challenge modern testing technologies and strategies.  <br /><br />You can browse the presentation abstracts, slides, and videos from last year on the <a href="https://developers.google.com/google-test-automation-conference/2013/">GTAC 2013 page</a>. <br /><br />Stay tuned to this blog and the GTAC website for application information and opportunities to present at GTAC. Subscribing to this blog is the best way to get notified. We're looking forward to seeing you there!  <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/gtac-2014-coming-to-seattlekirkland-in-october/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet:  Risk-Driven Testing</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-risk-driven-testing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-risk-driven-testing</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-risk-driven-testing/#comments</comments>
		<pubDate>Fri, 30 May 2014 23:10:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=5d168bea53db4e0194ac2a4295281b71</guid>
		<description><![CDATA[<i>by Peter Arrenbrecht</i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1QfmhsvpiCx__rcU0sr03Lu1fM1yhE8P9atyTgeLbRAQ/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><b><span>We are all conditioned to write tests</span></b> as we code: unit, functional, UI&#8212;the whole shebang. We are professionals, after all. Many of us like how small tests let us work quickly, and how larger tests inspire safety and closure. Or we may just anticipate flak during review. We are so used to these tests that often <b><span>we no longer question why we write them</span></b>. This can be wasteful and dangerous. <br /><br /><b><span>Tests are a means to an end:</span></b> To <span><b>reduce the key risks</b></span> of a project, and to <b><span>get the biggest bang for the buck</span></b>. This bang may not always come from the tests that standard practice has you write, or not even from tests at all. <br /><br />Two examples: <br /><br /><div><i>&#8220;We built a new debugging aid. We wrote unit, integration, and UI tests. We were ready to launch.&#8221;</i><br /><br />Outstanding practice. <b>Missing the mark.</b><br /><br />Our key risks were that we'd corrupt our data or bring down our servers for the sake of a debugging aid. None of the tests addressed this, but they gave a false sense of safety and &#8220;being done&#8221;.<br /><b>We stopped the launch.</b></div><br /><br /><div><i>&#8220;We wanted to turn down a feature, so we needed to alert affected users. Again we had unit and  integration tests, and even one expensive end-to-end test.&#8221;</i><br /><br />Standard practice. <b>Wasted effort.</b><br /><br />The alert was so critical it actually needed end-to-end coverage for all scenarios. But it would be live for only three releases. The cheapest effective test? Manual testing before each release.</div><br /><br /><b>A Better Approach: Risks First </b><br /><br />For every project or feature, <span><b>think about testing</b></span>. Brainstorm your key risks and your best options to reduce them. <span><b>Do this at the start</b></span> so you don't waste effort and can adapt your design. <b><span>Write them down</span></b> as a QA design so you can point to it in reviews and discussions. <br /><br />To be sure, <span><b>standard practice remains a good idea in most cases</b></span> (hence it&#8217;s standard). Small tests are cheap and speed up coding and maintenance, and larger tests safeguard core use-cases and integration. <br /><br /><span><b>Just remember</b></span>: Your tests are a means. <span><b>The bang is what counts</b></span>. It&#8217;s your job to <b><span>maximize it</span></b>. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Peter Arrenbrecht</i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1QfmhsvpiCx__rcU0sr03Lu1fM1yhE8P9atyTgeLbRAQ/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><b><span style="color: #990000;">We are all conditioned to write tests</span></b> as we code: unit, functional, UI—the whole shebang. We are professionals, after all. Many of us like how small tests let us work quickly, and how larger tests inspire safety and closure. Or we may just anticipate flak during review. We are so used to these tests that often <b><span style="color: #990000;">we no longer question why we write them</span></b>. This can be wasteful and dangerous. <br /><br /><b><span style="color: #990000;">Tests are a means to an end:</span></b> To <span style="color: #990000;"><b>reduce the key risks</b></span> of a project, and to <b><span style="color: #990000;">get the biggest bang for the buck</span></b>. This bang may not always come from the tests that standard practice has you write, or not even from tests at all. <br /><br />Two examples: <br /><br /><div style="background: #fef2cc; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><i>“We built a new debugging aid. We wrote unit, integration, and UI tests. We were ready to launch.”</i><br /><br />Outstanding practice. <b>Missing the mark.</b><br /><br />Our key risks were that we'd corrupt our data or bring down our servers for the sake of a debugging aid. None of the tests addressed this, but they gave a false sense of safety and “being done”.<br /><b>We stopped the launch.</b></div><br /><br /><div style="background: #fef2cc; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><i>“We wanted to turn down a feature, so we needed to alert affected users. Again we had unit and  integration tests, and even one expensive end-to-end test.”</i><br /><br />Standard practice. <b>Wasted effort.</b><br /><br />The alert was so critical it actually needed end-to-end coverage for all scenarios. But it would be live for only three releases. The cheapest effective test? Manual testing before each release.</div><br /><br /><b>A Better Approach: Risks First </b><br /><br />For every project or feature, <span style="color: #990000;"><b>think about testing</b></span>. Brainstorm your key risks and your best options to reduce them. <span style="color: #990000;"><b>Do this at the start</b></span> so you don't waste effort and can adapt your design. <b><span style="color: #990000;">Write them down</span></b> as a QA design so you can point to it in reviews and discussions. <br /><br />To be sure, <span style="color: #990000;"><b>standard practice remains a good idea in most cases</b></span> (hence it’s standard). Small tests are cheap and speed up coding and maintenance, and larger tests safeguard core use-cases and integration. <br /><br /><span style="color: #990000;"><b>Just remember</b></span>: Your tests are a means. <span style="color: #990000;"><b>The bang is what counts</b></span>. It’s your job to <b><span style="color: #990000;">maximize it</span></b>. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-risk-driven-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Effective Testing</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-effective-testing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-effective-testing</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-effective-testing/#comments</comments>
		<pubDate>Wed, 07 May 2014 17:10:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=9a052769c5e314fd0b62e7e35de40c01</guid>
		<description><![CDATA[<i>by Rich Martin, Zurich </i><br /><i><br /></i><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1pb8AvYvshNRAP4x2skdd4fc0U2reCBxsMlccwEdFlFs/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><br />Whether we are writing an individual unit test or designing a product&#8217;s entire testing process, it is important to take a step back and think about <span><b>how effective are our tests at detecting and reporting bugs in our code</b></span>. To be effective, there are <b><span>three important qualities</span></b> that every test should try to maximize: <br /><br /><b>Fidelity </b><br /><br />When the code under test is broken, the test fails. <b><span>A high&#173;-fidelity test is one which is very sensitive to defects in the code under test</span></b>, helping to prevent bugs from creeping into the code. <br /><br />Maximize fidelity by ensuring that your tests cover all the paths through your code and include all relevant assertions on the expected state. <br /><br /><b>Resilience </b><br /><br />A test shouldn&#8217;t fail if the code under test isn&#8217;t defective. <b><span>A resilient test is one that only fails when a breaking change is made to the code under test.</span></b> Refactorings and other non-&#173;breaking changes to the code under test can be made without needing to modify the test, reducing the cost of maintaining the tests. <br /><br />Maximize resilience by only testing the exposed API of the code under test&#894; avoid reaching into internals. Favor stubs and fakes over mocks&#894; don't verify interactions with dependencies unless it is that interaction that you are explicitly validating. A flaky test obviously has very low resilience. <br /><br /><b>Precision </b><br /><br />When a test fails, <b><span>a high&#173;-precision test tells you exactly where the defect lies</span></b>. A well&#173;-written unit test can tell you exactly which line of code is at fault. Poorly written tests (especially large end-to-end tests) often exhibit very low precision, telling you that something is broken but not where. <br /><br />Maximize precision by keeping your tests small and tightly &#173;focused. Choose descriptive method names that convey exactly what the test is validating. For system integration tests, validate state at every boundary. <br /><br />These three qualities are often in tension with each other. It's easy to write a highly resilient test (the empty test, for example), but writing a test that is both highly resilient and high&#173;-fidelity is hard. <b><span>As you design and write tests, use these qualities as a framework to guide your implementation</span></b>. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Rich Martin, Zurich </i><br /><i><br /></i><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1pb8AvYvshNRAP4x2skdd4fc0U2reCBxsMlccwEdFlFs/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><br />Whether we are writing an individual unit test or designing a product’s entire testing process, it is important to take a step back and think about <span style="color: #660000;"><b>how effective are our tests at detecting and reporting bugs in our code</b></span>. To be effective, there are <b><span style="color: #660000;">three important qualities</span></b> that every test should try to maximize: <br /><br /><b>Fidelity </b><br /><br />When the code under test is broken, the test fails. <b><span style="color: #660000;">A high­-fidelity test is one which is very sensitive to defects in the code under test</span></b>, helping to prevent bugs from creeping into the code. <br /><br />Maximize fidelity by ensuring that your tests cover all the paths through your code and include all relevant assertions on the expected state. <br /><br /><b>Resilience </b><br /><br />A test shouldn’t fail if the code under test isn’t defective. <b><span style="color: #660000;">A resilient test is one that only fails when a breaking change is made to the code under test.</span></b> Refactorings and other non-­breaking changes to the code under test can be made without needing to modify the test, reducing the cost of maintaining the tests. <br /><br />Maximize resilience by only testing the exposed API of the code under test; avoid reaching into internals. Favor stubs and fakes over mocks; don't verify interactions with dependencies unless it is that interaction that you are explicitly validating. A flaky test obviously has very low resilience. <br /><br /><b>Precision </b><br /><br />When a test fails, <b><span style="color: #660000;">a high­-precision test tells you exactly where the defect lies</span></b>. A well­-written unit test can tell you exactly which line of code is at fault. Poorly written tests (especially large end-to-end tests) often exhibit very low precision, telling you that something is broken but not where. <br /><br />Maximize precision by keeping your tests small and tightly ­focused. Choose descriptive method names that convey exactly what the test is validating. For system integration tests, validate state at every boundary. <br /><br />These three qualities are often in tension with each other. It's easy to write a highly resilient test (the empty test, for example), but writing a test that is both highly resilient and high­-fidelity is hard. <b><span style="color: #660000;">As you design and write tests, use these qualities as a framework to guide your implementation</span></b>. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-effective-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Test Behaviors, Not Methods</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-test-behaviors-not-methods/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-test-behaviors-not-methods</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-test-behaviors-not-methods/#comments</comments>
		<pubDate>Mon, 14 Apr 2014 21:25:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=e1dca3362eb6cf8838ecbcd2f3ffb1e7</guid>
		<description><![CDATA[<i>by Erik Kuefler </i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1W3BQgIYWZ-glc5kxvFGVE28uu4GAodAU1LU9-r4qwIs/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br />After writing a method, it's easy to write just one test that verifies everything the method does. But <span><b>it can be harmful to think that tests and public methods should have a 1:1 relationship</b></span>. What we really want to test are behaviors, where a single method can exhibit many behaviors, and a single behavior sometimes spans across multiple methods. <br /><br />Let's take a look at a bad test that verifies an entire method: <br /><br /><pre>@Test <span>public</span> <span>void</span> testProcessTransaction() {<br />  User user = newUserWithBalance(LOW_BALANCE_THRESHOLD.plus(dollars(2));<br />  transactionProcessor.processTransaction(<br />      user,<br /><span>new</span> Transaction(<span>"Pile of Beanie Babies"</span>, dollars(3)));<br />  assertContains(<span>"You bought a Pile of Beanie Babies"</span>, ui.getText());<br />  assertEquals(1, user.getEmails().size());<br />  assertEquals(<span>"Your balance is low"</span>, user.getEmails().get(0).getSubject());<br />}<br /></pre><br />Displaying the name of the purchased item and sending an email about the balance being low are two separate behaviors, but this test looks at both of those behaviors together just because they happen to be triggered by the same method. <span><b>Tests like this very often become massive and difficult to maintain over time as additional behaviors keep getting added in</b></span>&#8212;eventually it will be very hard to tell which parts of the input are responsible for which assertions. The fact that the test's name is a direct mirror of the method's name is a bad sign.  <br /><br /><b><span>It's a much better idea to use separate tests to verify separate behaviors</span></b>: <br /><br /><pre>@Test <span>public</span> <span>void</span> testProcessTransaction_displaysNotification() {<br />  transactionProcessor.processTransaction(<br /><span>new</span> User(), <span>new</span> Transaction(<span>"Pile of Beanie Babies"</span>));<br />  assertContains(<span>"You bought a Pile of Beanie Babies"</span>, ui.getText());<br />}<br />@Test <span>public</span> <span>void</span> testProcessTransaction_sendsEmailWhenBalanceIsLow() {<br />  User user = newUserWithBalance(LOW_BALANCE_THRESHOLD.plus(dollars(2));<br />  transactionProcessor.processTransaction(<br />      user,<br /><span>new</span> Transaction(dollars(3)));<br />  assertEquals(1, user.getEmails().size());<br />  assertEquals(<span>"Your balance is low"</span>, user.getEmails().get(0).getSubject());<br />}<br /></pre><br />Now, when someone adds a new behavior, they will write a new test for that behavior. Each test will remain focused and easy to understand, no matter how many behaviors are added. <b><span>This will make your tests more resilient since adding new behaviors is unlikely to break the existing tests, and clearer since each test contains code to exercise only one behavior</span></b>. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Erik Kuefler </i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1W3BQgIYWZ-glc5kxvFGVE28uu4GAodAU1LU9-r4qwIs/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br />After writing a method, it's easy to write just one test that verifies everything the method does. But <span style="color: purple;"><b>it can be harmful to think that tests and public methods should have a 1:1 relationship</b></span>. What we really want to test are behaviors, where a single method can exhibit many behaviors, and a single behavior sometimes spans across multiple methods. <br /><br />Let's take a look at a bad test that verifies an entire method: <br /><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">@Test <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> testProcessTransaction() {<br />  User user = newUserWithBalance(LOW_BALANCE_THRESHOLD.plus(dollars(2));<br />  transactionProcessor.processTransaction(<br />      user,<br />      <span style="color: #0433ff;">new</span> Transaction(<span style="color: #ff2600;">"Pile of Beanie Babies"</span>, dollars(3)));<br />  assertContains(<span style="color: #ff2600;">"You bought a Pile of Beanie Babies"</span>, ui.getText());<br />  assertEquals(1, user.getEmails().size());<br />  assertEquals(<span style="color: #ff2600;">"Your balance is low"</span>, user.getEmails().get(0).getSubject());<br />}<br /></pre><br />Displaying the name of the purchased item and sending an email about the balance being low are two separate behaviors, but this test looks at both of those behaviors together just because they happen to be triggered by the same method. <span style="color: purple;"><b>Tests like this very often become massive and difficult to maintain over time as additional behaviors keep getting added in</b></span>—eventually it will be very hard to tell which parts of the input are responsible for which assertions. The fact that the test's name is a direct mirror of the method's name is a bad sign.  <br /><br /><b><span style="color: purple;">It's a much better idea to use separate tests to verify separate behaviors</span></b>: <br /><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">@Test <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> testProcessTransaction_displaysNotification() {<br />  transactionProcessor.processTransaction(<br />      <span style="color: #0433ff;">new</span> User(), <span style="color: #0433ff;">new</span> Transaction(<span style="color: #ff2600;">"Pile of Beanie Babies"</span>));<br />  assertContains(<span style="color: #ff2600;">"You bought a Pile of Beanie Babies"</span>, ui.getText());<br />}<br />@Test <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> testProcessTransaction_sendsEmailWhenBalanceIsLow() {<br />  User user = newUserWithBalance(LOW_BALANCE_THRESHOLD.plus(dollars(2));<br />  transactionProcessor.processTransaction(<br />      user,<br />      <span style="color: #0433ff;">new</span> Transaction(dollars(3)));<br />  assertEquals(1, user.getEmails().size());<br />  assertEquals(<span style="color: #ff2600;">"Your balance is low"</span>, user.getEmails().get(0).getSubject());<br />}<br /></pre><br />Now, when someone adds a new behavior, they will write a new test for that behavior. Each test will remain focused and easy to understand, no matter how many behaviors are added. <b><span style="color: purple;">This will make your tests more resilient since adding new behaviors is unlikely to break the existing tests, and clearer since each test contains code to exercise only one behavior</span></b>. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-test-behaviors-not-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>The *Real* Test Driven Development</title>
		<link>https://googledata.org/google-testing/the-real-test-driven-development/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-real-test-driven-development</link>
		<comments>https://googledata.org/google-testing/the-real-test-driven-development/#comments</comments>
		<pubDate>Tue, 01 Apr 2014 09:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=6a38d0ae3e632f0524c1dbb34d168b98</guid>
		<description><![CDATA[<i></i><br /><div><span><b>Update: APRIL FOOLS!</b></span></div><div><br /></div><i><br /></i><i>by Kaue Silveira </i><br /><br />Here at Google, we invest heavily in development productivity research. In fact, our TDD research group now occupies nearly an entire building of the <a href="http://en.wikipedia.org/wiki/Googleplex">Googleplex</a>. The group has been working hard to minimize the development cycle time, and we&#8217;d like to share some of the amazing progress they&#8217;ve made. <br /><br /><b>The Concept </b><br /><br />In the ways of old, it used to be that people wrote tests for their existing code. This was changed by TDD (Test-driven Development), where one would write the test first and then write the code to satisfy it. The TDD research group didn&#8217;t think this was enough and wanted to elevate the humble test to the next level. We are pleased to announce the <b>Real</b> TDD, our latest innovation in the <a href="http://en.wikipedia.org/wiki/Program_synthesis">Program Synthesis</a> field, where you write only the tests and have the computer write the code for you!<br /><br />The following graph shows how the number of tests created by a small feature team grew since they started using this tool towards the end of 2013. Over the last 2 quarters, more than 89% of this team&#8217;s production code was written by the tool! <br /><br /><div><a href="http://2.bp.blogspot.com/-L7u928SyPZo/UzYwxxJnJ_I/AAAAAAAAAFk/4NPxE5h691o/s1600/image.png"><img border="0" src="http://2.bp.blogspot.com/-L7u928SyPZo/UzYwxxJnJ_I/AAAAAAAAAFk/4NPxE5h691o/s1600/image.png" height="393" width="640"></a></div><b>See it in action: </b><br /><br />Test written by a Software Engineer: <br /><br /><pre><span>class</span> LinkGeneratorTest(googletest.TestCase):<br /><br /><span>def</span> setUp(<span>self</span>):<br /><span>self</span>.generator = link_generator.LinkGenerator()<br /><br /><span>def</span> testGetLinkFromIDs(<span>self</span>):<br />    expected = (<span>'https://frontend.google.com/advancedSearchResults?'</span><br /><span>'s.op=ALL&#38;s.r0.field=ID&#38;s.r0.val=1288585+1310696+1346270+'</span>)<br />    actual = <span>self</span>.generator.GetLinkFromIDs(set((1346270, 1310696, 1288585)))<br /><span>self</span>.assertEqual(expected, actual)</pre><br />Code created by our tool: <br /><br /><pre><span>import</span> urllib<br /><br /><span>class</span> LinkGenerator(object):<br /><br />  _URL = (<br /><span>'https://frontend.google.com/advancedSearchResults?'</span><br /><span>'s.op=ALL&#38;s.r0.field=ID&#38;s.r0.val='</span>)<br /><br /><span>def</span> GetLinkFromIDs(<span>self</span>, ids):<br />    result = []<br /><span>for</span> id <span>in</span> sorted(ids):<br />      result.append(<span>'%s '</span> % id)<br /><span>return</span> <span>self</span>._URL + urllib.quote_plus(<span>''</span>.join(result))<br /></pre><br />Note that the tool is smart enough to not generate the obvious implementation of returning a constant string, but instead it correctly abstracts and generalizes the relation between inputs and outputs. It becomes smarter at every use and it&#8217;s behaving more and more like a human programmer every day. We once saw a comment in the generated code that said "I need some coffee". <br /><br /><b>How does it work? </b><br /><br />We&#8217;ve trained the <a href="http://en.wikipedia.org/wiki/Google_Brain">Google Brain</a> with billions of lines of open-source software to learn about coding patterns and how product code correlates with test code. Its accuracy is further improved by using  <a href="http://en.wikipedia.org/wiki/Type_inference">Type Inference</a> to infer types from code and the <a href="https://www.youtube.com/watch?v=h0OkptwfX4g&#38;feature=youtu.be&#38;t=21m30s">Girard-Reynolds Isomorphism</a> to infer code from types. <br /><br />The tool runs every time your unit test is saved, and it uses the learned model to guide a backtracking search for a code snippet that satisfies all assertions in the test. It provides sub-second responses for 99.5% of the cases (as shown in the following graph), thanks to millions of pre-computed assertion-snippet pairs stored in <a href="http://en.wikipedia.org/wiki/Spanner_(database)">Spanner</a> for global low-latency access. <br /><br /><div><a href="http://2.bp.blogspot.com/-nH9kf2nDmPk/UzYxCZvYD0I/AAAAAAAAAFs/bhiaJW-qwjU/s1600/image+(1).png"><img border="0" src="http://2.bp.blogspot.com/-nH9kf2nDmPk/UzYxCZvYD0I/AAAAAAAAAFs/bhiaJW-qwjU/s1600/image+(1).png" height="394" width="640"></a></div><br /><br /><b>How can I use it? </b><br /><br />We will offer a free (rate-limited) service that everyone can use, once we have sorted out the legal issues regarding the possibility of mixing code snippets originating from open-source projects with different licenses (e.g., <a href="http://en.wikipedia.org/wiki/GNU_General_Public_License">GPL-licensed</a> tests will simply refuse to pass <a href="http://en.wikipedia.org/wiki/BSD_licenses">BSD-licensed</a> code snippets). If you would like to try our alpha release before the public launch, leave us a comment! <br /><br />]]></description>
				<content:encoded><![CDATA[<i></i><br /><div style="text-align: center;"><span style="color: red;"><b>Update: APRIL FOOLS!</b></span></div><div><br /></div><i><br /></i><i>by Kaue Silveira </i><br /><br />Here at Google, we invest heavily in development productivity research. In fact, our TDD research group now occupies nearly an entire building of the <a href="http://en.wikipedia.org/wiki/Googleplex">Googleplex</a>. The group has been working hard to minimize the development cycle time, and we’d like to share some of the amazing progress they’ve made. <br /><br /><b>The Concept </b><br /><br />In the ways of old, it used to be that people wrote tests for their existing code. This was changed by TDD (Test-driven Development), where one would write the test first and then write the code to satisfy it. The TDD research group didn’t think this was enough and wanted to elevate the humble test to the next level. We are pleased to announce the <b>Real</b> TDD, our latest innovation in the <a href="http://en.wikipedia.org/wiki/Program_synthesis">Program Synthesis</a> field, where you write only the tests and have the computer write the code for you!<br /><br />The following graph shows how the number of tests created by a small feature team grew since they started using this tool towards the end of 2013. Over the last 2 quarters, more than 89% of this team’s production code was written by the tool! <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-L7u928SyPZo/UzYwxxJnJ_I/AAAAAAAAAFk/4NPxE5h691o/s1600/image.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-L7u928SyPZo/UzYwxxJnJ_I/AAAAAAAAAFk/4NPxE5h691o/s1600/image.png" height="393" width="640" /></a></div><b>See it in action: </b><br /><br />Test written by a Software Engineer: <br /><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">class</span> LinkGeneratorTest(googletest.TestCase):<br /><br />  <span style="color: #0433ff;">def</span> setUp(<span style="color: #0433ff;">self</span>):<br />    <span style="color: #0433ff;">self</span>.generator = link_generator.LinkGenerator()<br /><br />  <span style="color: #0433ff;">def</span> testGetLinkFromIDs(<span style="color: #0433ff;">self</span>):<br />    expected = (<span style="color: #ff2600;">'https://frontend.google.com/advancedSearchResults?'</span><br />                <span style="color: #ff2600;">'s.op=ALL&amp;s.r0.field=ID&amp;s.r0.val=1288585+1310696+1346270+'</span>)<br />    actual = <span style="color: #0433ff;">self</span>.generator.GetLinkFromIDs(set((1346270, 1310696, 1288585)))<br />    <span style="color: #0433ff;">self</span>.assertEqual(expected, actual)</pre><br />Code created by our tool: <br /><br /><pre style="background: #f0f0f0; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">import</span> urllib<br /><br /><span style="color: #0433ff;">class</span> LinkGenerator(object):<br /><br />  _URL = (<br />      <span style="color: #ff2600;">'https://frontend.google.com/advancedSearchResults?'</span><br />      <span style="color: #ff2600;">'s.op=ALL&amp;s.r0.field=ID&amp;s.r0.val='</span>)<br /><br />  <span style="color: #0433ff;">def</span> GetLinkFromIDs(<span style="color: #0433ff;">self</span>, ids):<br />    result = []<br />    <span style="color: #0433ff;">for</span> id <span style="color: #0433ff;">in</span> sorted(ids):<br />      result.append(<span style="color: #ff2600;">'%s '</span> % id)<br />    <span style="color: #0433ff;">return</span> <span style="color: #0433ff;">self</span>._URL + urllib.quote_plus(<span style="color: #ff2600;">''</span>.join(result))<br /></pre><br />Note that the tool is smart enough to not generate the obvious implementation of returning a constant string, but instead it correctly abstracts and generalizes the relation between inputs and outputs. It becomes smarter at every use and it’s behaving more and more like a human programmer every day. We once saw a comment in the generated code that said "I need some coffee". <br /><br /><b>How does it work? </b><br /><br />We’ve trained the <a href="http://en.wikipedia.org/wiki/Google_Brain">Google Brain</a> with billions of lines of open-source software to learn about coding patterns and how product code correlates with test code. Its accuracy is further improved by using  <a href="http://en.wikipedia.org/wiki/Type_inference">Type Inference</a> to infer types from code and the <a href="https://www.youtube.com/watch?v=h0OkptwfX4g&amp;feature=youtu.be&amp;t=21m30s">Girard-Reynolds Isomorphism</a> to infer code from types. <br /><br />The tool runs every time your unit test is saved, and it uses the learned model to guide a backtracking search for a code snippet that satisfies all assertions in the test. It provides sub-second responses for 99.5% of the cases (as shown in the following graph), thanks to millions of pre-computed assertion-snippet pairs stored in <a href="http://en.wikipedia.org/wiki/Spanner_(database)">Spanner</a> for global low-latency access. <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-nH9kf2nDmPk/UzYxCZvYD0I/AAAAAAAAAFs/bhiaJW-qwjU/s1600/image+(1).png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-nH9kf2nDmPk/UzYxCZvYD0I/AAAAAAAAAFs/bhiaJW-qwjU/s1600/image+(1).png" height="394" width="640" /></a></div><br /><br /><b>How can I use it? </b><br /><br />We will offer a free (rate-limited) service that everyone can use, once we have sorted out the legal issues regarding the possibility of mixing code snippets originating from open-source projects with different licenses (e.g., <a href="http://en.wikipedia.org/wiki/GNU_General_Public_License">GPL-licensed</a> tests will simply refuse to pass <a href="http://en.wikipedia.org/wiki/BSD_licenses">BSD-licensed</a> code snippets). If you would like to try our alpha release before the public launch, leave us a comment! <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/the-real-test-driven-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: What Makes a Good Test?</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-what-makes-a-good-test/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-what-makes-a-good-test</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-what-makes-a-good-test/#comments</comments>
		<pubDate>Tue, 18 Mar 2014 22:10:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=f6cef583b1900b373dff33de2ee22942</guid>
		<description><![CDATA[<i>by Erik Kuefler </i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1C51MIOYAy699S5Sm2WRDsCnutUIQyi7Tzw5EbhRo_Mo/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br />Unit tests are important tools for verifying that our code is correct. But <span><b>writing good tests is about much more than just verifying correctness</b></span> &#8212; a good unit test should exhibit several other properties in order to be readable and maintainable. <br /><br />One property of a good test is clarity. <b><span>Clarity means that a test should serve as readable documentation for humans, describing the code being tested in terms of its public APIs.</span></b> Tests shouldn't refer directly to implementation details. The names of a class's tests should say everything the class does, and the tests themselves should serve as examples for how to use the class. <br /><br />Two more important properties are completeness and conciseness. <b><span>A test is complete when its body contains all of the information you need to understand it, and concise when it doesn't contain any other distracting information.</span></b> This test fails on both counts: <br /><br /><pre>@Test <span>public</span> <span>void</span> shouldPerformAddition() {<br />  Calculator <b>calculator</b> = <span>new</span> Calculator(<span>new</span> RoundingStrategy(), <br /><span>"unused"</span>, ENABLE_COSIN_FEATURE, 0.01, calculusEngine, <span>false</span>);<br /><span>int</span> <b>result</b> = <b>calculator</b>.doComputation(makeTestComputation());<br />  assertEquals(<b>5</b>, <b>result</b>); <span>// Where did this number come from?</span><br />}</pre><br />Lots of distracting information is being passed to the constructor, and the important parts are hidden off in a helper method. The test can be made more complete by clarifying the purpose of the helper method, and more concise by using another helper to hide the irrelevant details of constructing the calculator: <br /><br /><pre>@Test <span>public</span> <span>void</span> shouldPerformAddition() {<br />  Calculator <b>calculator</b> = newCalculator();<br /><span>int</span> <b>result</b> = <b>calculator</b>.doComputation(makeAdditionComputation(<b>2</b>, <b>3</b>));<br />  assertEquals(<b>5</b>, <b>result</b>);<br />}</pre><br />One final property of a good test is resilience. Once written, a <b><span>resilient test doesn't have to change unless the purpose or behavior of the class being tested changes</span></b>. Adding new behavior should only require adding new tests, not changing old ones. The original test above isn't resilient since you'll have to update it (and probably dozens of other tests!) whenever you add a new irrelevant constructor parameter. Moving these details into the helper method solved this problem. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Erik Kuefler </i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/document/d/1C51MIOYAy699S5Sm2WRDsCnutUIQyi7Tzw5EbhRo_Mo/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br />Unit tests are important tools for verifying that our code is correct. But <span style="color: purple;"><b>writing good tests is about much more than just verifying correctness</b></span> — a good unit test should exhibit several other properties in order to be readable and maintainable. <br /><br />One property of a good test is clarity. <b><span style="color: purple;">Clarity means that a test should serve as readable documentation for humans, describing the code being tested in terms of its public APIs.</span></b> Tests shouldn't refer directly to implementation details. The names of a class's tests should say everything the class does, and the tests themselves should serve as examples for how to use the class. <br /><br />Two more important properties are completeness and conciseness. <b><span style="color: purple;">A test is complete when its body contains all of the information you need to understand it, and concise when it doesn't contain any other distracting information.</span></b> This test fails on both counts: <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">@Test <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> shouldPerformAddition() {<br />  Calculator <b>calculator</b> = <span style="color: #0433ff;">new</span> Calculator(<span style="color: #0433ff;">new</span> RoundingStrategy(), <br />      <span style="color: #ff2600;">"unused"</span>, ENABLE_COSIN_FEATURE, 0.01, calculusEngine, <span style="color: #0433ff;">false</span>);<br />  <span style="color: #0433ff;">int</span> <b>result</b> = <b>calculator</b>.doComputation(makeTestComputation());<br />  assertEquals(<b>5</b>, <b>result</b>); <span style="color: #4f8f00;">// Where did this number come from?</span><br />}</pre><br />Lots of distracting information is being passed to the constructor, and the important parts are hidden off in a helper method. The test can be made more complete by clarifying the purpose of the helper method, and more concise by using another helper to hide the irrelevant details of constructing the calculator: <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">@Test <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> shouldPerformAddition() {<br />  Calculator <b>calculator</b> = newCalculator();<br />  <span style="color: #0433ff;">int</span> <b>result</b> = <b>calculator</b>.doComputation(makeAdditionComputation(<b>2</b>, <b>3</b>));<br />  assertEquals(<b>5</b>, <b>result</b>);<br />}</pre><br />One final property of a good test is resilience. Once written, a <b><span style="color: purple;">resilient test doesn't have to change unless the purpose or behavior of the class being tested changes</span></b>. Adding new behavior should only require adding new tests, not changing old ones. The original test above isn't resilient since you'll have to update it (and probably dozens of other tests!) whenever you add a new irrelevant constructor parameter. Moving these details into the helper method solved this problem. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-what-makes-a-good-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>When/how to use Mockito Answer</title>
		<link>https://googledata.org/google-testing/whenhow-to-use-mockito-answer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=whenhow-to-use-mockito-answer</link>
		<comments>https://googledata.org/google-testing/whenhow-to-use-mockito-answer/#comments</comments>
		<pubDate>Mon, 03 Mar 2014 21:19:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=a243a677e729a4a9b268a158e02d6af8</guid>
		<description><![CDATA[<i>by Hongfei Ding, Software Engineer, Shanghai </i><br /><br /><a href="https://code.google.com/p/mockito/">Mockito</a> is a popular open source Java testing framework that allows the creation of mock objects. For example, we have the below interface used in our SUT (System Under Test):<br /><pre><span>interface</span> Service {<br />  Data get();<br />}</pre><br />In our test, normally we want to fake the <span><b>Service</b></span>&#8217;s behavior to return canned data, so that the unit test can focus on testing the code that interacts with the <span><b>Service</b></span>. We use <span><b>when-return</b></span> clause to stub a method.<br /><pre>when(service.get()).thenReturn(cannedData);</pre><br />But sometimes you need mock object behavior that's too complex for <span><b>when-return</b></span>. An <a href="http://docs.mockito.googlecode.com/hg/latest/org/mockito/stubbing/Answer.html"><span>Answer</span></a> object can be a clean way to do this once you get the syntax right.<br /><br />A common usage of <span><b>Answer</b></span> is to <b>stub asynchronous methods that have callbacks</b>. For example, we have mocked the interface below:<br /><pre><span>interface</span> Service {<br /><span>void</span> get(Callback callback);<br />}</pre><br />Here you&#8217;ll find that <span><b>when-return</b></span> is not that helpful anymore. <span><b>Answer</b></span> is the replacement. For example, we can <b>emulate a success</b> by calling the <span><b>onSuccess</b></span> function of the callback.<br /><pre>doAnswer(<span>new</span> Answer&#60;Void&#62;() {<br /><span>public</span> Void answer(InvocationOnMock invocation) {<br />       Callback callback = (Callback) invocation.getArguments()[0];<br />       callback.onSuccess(cannedData);<br /><span>return</span> null;<br />    }<br />}).when(service).get(any(Callback.<span>class</span>));</pre><br /><span><b>Answer</b></span> can also be used to <b>make smarter stubs for synchronous methods</b>. Smarter here means the stub can return a value depending on the input, rather than canned data. It&#8217;s sometimes quite useful. For example, we have mocked the <span><b>Translator</b></span>&#160;interface below:<br /><pre><span>interface</span> Translator {<br />  String translate(String msg);<br />}</pre><br />We might choose to mock <span><b>Translator</b></span> to return a constant string and then assert the result. However, that test is not thorough, because the input to the <span><b>translator</b></span>&#160;function has been ignored. To improve this, we might capture the input and do extra verification, but then we start to fall into the &#8220;<a href="http://googletesting.blogspot.tw/2013/03/testing-on-toilet-testing-state-vs.html">testing interaction rather than testing state</a>&#8221; trap.  <br /><br />A good usage of <span><b>Answer</b></span> is <b>to reverse the input message as a fake translation</b>. So that both things are assured by checking the result string: 1) <span><b>translate</b></span> has been invoked, 2) the <span><b>msg</b></span> being translated is correct. Notice that this time we&#8217;ve used <span><b>thenAnswer</b></span> syntax, a twin of <span><b>doAnswer</b></span>, for stubbing a non-void method.<br /><pre>when(translator.translate(any(String.<span>class</span>))).thenAnswer(reverseMsg())<br />...<br /><span>// extracted a method to put a descriptive name</span><br /><span>private</span> <span>static</span> Answer&#60;String&#62; reverseMsg() { <br /><span>return</span> <span>new</span> Answer&#60;String&#62;() {<br /><span>public</span> String answer(InvocationOnMock invocation) {<br /><span>return</span> reverseString((String) invocation.getArguments()[0]));<br />    }<br />  }<br />}</pre><br />Last but not least, if you find yourself writing many nontrivial <span><b>Answer</b></span>s, you should consider using a <a href="http://googletesting.blogspot.com/2013/06/testing-on-toilet-fake-your-way-to.html">fake</a> instead. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Hongfei Ding, Software Engineer, Shanghai </i><br /><br /><a href="https://code.google.com/p/mockito/">Mockito</a> is a popular open source Java testing framework that allows the creation of mock objects. For example, we have the below interface used in our SUT (System Under Test):<br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">interface</span> Service {<br />  Data get();<br />}</pre><br />In our test, normally we want to fake the <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>Service</b></span>’s behavior to return canned data, so that the unit test can focus on testing the code that interacts with the <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>Service</b></span>. We use <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>when-return</b></span> clause to stub a method.<br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">when(service.get()).thenReturn(cannedData);</pre><br />But sometimes you need mock object behavior that's too complex for <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>when-return</b></span>. An <a href="http://docs.mockito.googlecode.com/hg/latest/org/mockito/stubbing/Answer.html"><span style="font-family: Courier New, Courier, monospace;">Answer</span></a> object can be a clean way to do this once you get the syntax right.<br /><br />A common usage of <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>Answer</b></span> is to <b>stub asynchronous methods that have callbacks</b>. For example, we have mocked the interface below:<br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">interface</span> Service {<br />  <span style="color: #0433ff;">void</span> get(Callback callback);<br />}</pre><br />Here you’ll find that <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>when-return</b></span> is not that helpful anymore. <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>Answer</b></span> is the replacement. For example, we can <b>emulate a success</b> by calling the <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>onSuccess</b></span> function of the callback.<br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">doAnswer(<span style="color: #0433ff;">new</span> Answer&lt;Void&gt;() {<br />    <span style="color: #0433ff;">public</span> Void answer(InvocationOnMock invocation) {<br />       Callback callback = (Callback) invocation.getArguments()[0];<br />       callback.onSuccess(cannedData);<br />       <span style="color: #0433ff;">return</span> null;<br />    }<br />}).when(service).get(any(Callback.<span style="color: #0433ff;">class</span>));</pre><br /><span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>Answer</b></span> can also be used to <b>make smarter stubs for synchronous methods</b>. Smarter here means the stub can return a value depending on the input, rather than canned data. It’s sometimes quite useful. For example, we have mocked the <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>Translator</b></span>&nbsp;interface below:<br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">interface</span> Translator {<br />  String translate(String msg);<br />}</pre><br />We might choose to mock <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>Translator</b></span> to return a constant string and then assert the result. However, that test is not thorough, because the input to the <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>translator</b></span>&nbsp;function has been ignored. To improve this, we might capture the input and do extra verification, but then we start to fall into the “<a href="http://googletesting.blogspot.tw/2013/03/testing-on-toilet-testing-state-vs.html">testing interaction rather than testing state</a>” trap.  <br /><br />A good usage of <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>Answer</b></span> is <b>to reverse the input message as a fake translation</b>. So that both things are assured by checking the result string: 1) <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>translate</b></span> has been invoked, 2) the <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>msg</b></span> being translated is correct. Notice that this time we’ve used <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>thenAnswer</b></span> syntax, a twin of <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>doAnswer</b></span>, for stubbing a non-void method.<br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">when(translator.translate(any(String.<span style="color: #0433ff;">class</span>))).thenAnswer(reverseMsg())<br />...<br /><span style="color: #4f8f00;">// extracted a method to put a descriptive name</span><br /><span style="color: #0433ff;">private</span> <span style="color: #0433ff;">static</span> Answer&lt;String&gt; reverseMsg() { <br />  <span style="color: #0433ff;">return</span> <span style="color: #0433ff;">new</span> Answer&lt;String&gt;() {<br />    <span style="color: #0433ff;">public</span> String answer(InvocationOnMock invocation) {<br />       <span style="color: #0433ff;">return</span> reverseString((String) invocation.getArguments()[0]));<br />    }<br />  }<br />}</pre><br />Last but not least, if you find yourself writing many nontrivial <span style="color: #38761d; font-family: Courier New, Courier, monospace;"><b>Answer</b></span>s, you should consider using a <a href="http://googletesting.blogspot.com/2013/06/testing-on-toilet-fake-your-way-to.html">fake</a> instead. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/whenhow-to-use-mockito-answer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Minimizing Unreproducible Bugs</title>
		<link>https://googledata.org/google-testing/minimizing-unreproducible-bugs/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=minimizing-unreproducible-bugs</link>
		<comments>https://googledata.org/google-testing/minimizing-unreproducible-bugs/#comments</comments>
		<pubDate>Mon, 03 Feb 2014 19:23:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=1bfb81e6d0dcd91d07751b1497bd77a7</guid>
		<description><![CDATA[<div><a href="http://4.bp.blogspot.com/-W_7cqFXE2DA/Uu_ksr9HQOI/AAAAAAAAAFM/63eqQLF0cR8/s1600/cannot-repro.png"><img border="0" src="http://4.bp.blogspot.com/-W_7cqFXE2DA/Uu_ksr9HQOI/AAAAAAAAAFM/63eqQLF0cR8/s1600/cannot-repro.png" height="307" width="320"></a></div><br /><br /><i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><br />Unreproducible bugs are the bane of my existence. Far too often, I find a bug, report it, and hear back that it&#8217;s not a bug because it can&#8217;t be reproduced. Of course, the bug is still there, waiting to prey on its next victim. These types of bugs can be very expensive due to increased investigation time and overall lifetime. They can also have a damaging effect on product perception when users reporting these bugs are effectively ignored. We should be doing more to prevent them. In this article, I&#8217;ll go over some obvious, and maybe not so obvious, development/testing guidelines that can reduce the likelihood of these bugs from occurring. <br /><br /><br /><b><span>Avoid and test for race conditions, deadlocks, timing issues, memory corruption, uninitialized memory access, memory leaks, and resource issues </span></b><br /><br />I am lumping together many bug types in this section, but they are all related somewhat by how we test for them and how disproportionately hard they are to reproduce and debug. The root cause and effect can be separated by milliseconds or hours, and stack traces might be nonexistent or misleading. A system may fail in strange ways when exposed to unusual traffic spikes or insufficient resources. Race conditions and deadlocks may only be discovered during unique traffic patterns or resource configurations. Timing issues may only be noticed when many components are integrated and their performance parameters and failure/retry/timeout delays create a chaotic system. Memory corruption or uninitialized memory access may go unnoticed for a large percentage of calls but become fatal for rare states. Memory leaks may be negligible unless the system is exposed to load for an extended period of time. <br /><br /><u>Guidelines for development: </u><br /><br /><ul><li>Simplify your synchronization logic. If it&#8217;s too hard to understand, it will be difficult to reproduce and debug complex concurrency problems. </li><li>Always obtain locks in the same order. This is a tried-and-true guideline to avoid deadlocks, but I still see code that breaks it periodically. Define an order for obtaining multiple locks and never change that order.  </li><li>Don&#8217;t optimize by creating many fine-grained locks, unless you have verified that they are needed. Extra locks increase concurrency complexity. </li><li>Avoid shared memory, unless you truly need it. Shared memory access is very easy to get wrong, and the bugs may be quite difficult to reproduce. </li></ul><br /><u>Guidelines for testing: </u><br /><br /><ul><li><a href="http://en.wikipedia.org/wiki/Stress_testing">Stress test</a> your system regularly. You don't want to be surprised by unexpected failures when your system is under heavy load.  </li><li>Test timeouts. Create tests that mock/fake dependencies to test timeout code. If your timeout code does something bad, it may cause a bug that only occurs under certain system conditions. </li><li>Test with debug and optimized builds. You may find that a well behaved debug build works fine, but the system fails in strange ways once optimized. </li><li>Test under constrained resources. Try reducing the number of data centers, machines, processes, threads, available disk space, or available memory. Also try simulating reduced network bandwidth. </li><li>Test for longevity. Some bugs require a long period of time to reveal themselves. For example, persistent data may become corrupt over time. </li><li>Use dynamic analysis tools like <a href="http://en.wikipedia.org/wiki/Memory_debugger">memory debuggers</a>, <a href="https://code.google.com/p/address-sanitizer/">ASan</a>, <a href="https://code.google.com/p/thread-sanitizer/">TSan</a>, and <a href="https://code.google.com/p/memory-sanitizer/wiki/MemorySanitizer">MSan</a> regularly. They can help identify many categories of unreproducible memory/threading issues. </li></ul><br /><br /><b><span>Enforce preconditions </span></b><br /><br />I&#8217;ve seen many well-meaning functions with a high tolerance for bad input. For example, consider this function: <br /><br /><pre><span>void</span> ScheduleEvent(<span>int</span> timeDurationMilliseconds) {<br /><span>if</span> (timeDurationMilliseconds &#60;= 0) {<br />    timeDurationMilliseconds = 1;<br />  }<br />  ...<br />}<br /></pre><br />This function is trying to help the calling code by adjusting the input to an acceptable value, but it may be doing damage by masking a bug. The calling code may be experiencing any number of problems described in this article, and passing garbage to this function will always work fine. The more functions that are written with this level of tolerance, the harder it is to trace back to the root cause, and the more likely it becomes that the end user will see garbage. Enforcing preconditions, for instance by using asserts, may actually cause a higher number of failures for new systems, but as systems mature, and many minor/major problems are identified early on, these checks can help improve long-term reliability. <br /><br /><u>Guidelines for development: </u><br /><br /><ul><li>Enforce preconditions in your functions unless you have a good reason not to. </li></ul><br /><br /><b><span>Use defensive programming </span></b><br /><br /><a href="http://en.wikipedia.org/wiki/Defensive_programming">Defensive programming</a> is another tried-and-true technique that is great at minimizing unreproducible bugs. If your code calls a dependency to do something, and that dependency quietly fails or returns garbage, how does your code handle it? You could test for situations like this via mocking or faking, but it&#8217;s even better to have your production code do sanity checking on its dependencies. For example: <br /><br /><pre><span>double</span> GetMonthlyLoanPayment() {<br /><span>double</span> rate = GetTodaysInterestRateFromExternalSystem();<br /><span>if</span> (rate &#60; 0.001 &#124;&#124; rate &#62; 0.5) {<br /><span>throw</span> BadInterestRate(rate);<br />  }<br />  ...<br />}<br /></pre><br /><u>Guidelines for development: </u><br /><br /><ul><li>When possible, use defensive programming to verify the work of your dependencies with known risks of failure like user-provided data, I/O operations, and RPC calls. </li></ul><br /><u>Guidelines for testing: </u><br /><br /><ul><li>Use <a href="http://en.wikipedia.org/wiki/Fuzz_testing">fuzz testing</a> to test your systems hardiness when enduring bad data. </li></ul><br /><br /><b><span>Don&#8217;t hide all errors from the user </span></b><br /><br />There has been a trend in recent years toward hiding failures from users at all costs. In many cases, it makes perfect sense, but in some, we have gone overboard. Code that is very quiet and permissive during minor failures will allow an uninformed user to continue working in a failed state. The software may ultimately reach a fatal tipping point, and all the error conditions that led to failure have been ignored. If the user doesn&#8217;t know about the prior errors, they will not be able to report them, and you may not be able to reproduce them. <br /><br /><u>Guidelines for development: </u><br /><br /><ul><li>Only hide errors from the user when you are certain that there is no impact to system state or the user. </li><li>Any error with impact to the user should be reported to the user with instructions for how to proceed. The information shown to the user, combined with data available to an engineer, should be enough to determine what went wrong. </li></ul><br /><br /><b><span>Test error handling </span></b><br /><br />The most common sections of code to remain untested is error handling code. Don&#8217;t skip test coverage here. Bad error handling code can cause unreproducible bugs and create great risk if it does not handle fatal errors well. <br /><br /><u>Guidelines for testing: </u><br /><br /><ul><li>Always test your error handling code. This is usually best accomplished by mocking or faking the component triggering the error. </li><li>It&#8217;s also a good practice to examine your log quality for all types of error handling.  </li></ul><br /><br /><b><span>Check for duplicate keys </span></b><br /><br />If unique identifiers or data access keys are generated using random data or are not guaranteed to be globally unique, duplicate keys may cause data corruption or concurrency issues. Key duplication bugs are very difficult to reproduce. <br /><br /><u>Guidelines for development: </u><br /><br /><ul><li>Try to guarantee uniqueness of all keys. </li><li>When not possible to guarantee unique keys, check if the recently generated key is already in use before using it. </li><li>Watch out for potential race conditions here and avoid them with synchronization. </li></ul><br /><br /><b><span>Test for concurrent data access </span></b><br /><br />Some bugs only reveal themselves when multiple clients are reading/writing the same data. Your stress tests might be covering cases like these, but if they are not, you should have special tests for concurrent data access. Case like these are often unreproducible. For example, a user may have two instances of your app running against the same account, and they may not realize this when reporting a bug. <br /><br /><u>Guidelines for testing: </u><br /><br /><ul><li>Always test for concurrent data access if it&#8217;s a feature of the system. Actually, even if it&#8217;s not a feature, verify that the system rejects it. Testing concurrency can be challenging. An approach that usually works for me is to create many worker threads that simultaneously attempt access and a master thread that monitors and verifies that some number of attempts were indeed concurrent, blocked or allowed as expected, and all were successful. Programmatic post-analysis of all attempts and changing system state may also be necessary to ensure that the system behaved well. </li></ul><br /><br /><b><span>Steer clear of undefined behavior and non-deterministic access to data </span></b><br /><br />Some APIs and basic operations have warnings about <a href="http://en.wikipedia.org/wiki/Undefined_behavior">undefined behavior</a> when in certain states or provided with certain input. Similarly, some data structures do not guarantee an iteration order (example: <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Set.html#iterator()">Java&#8217;s Set</a>). Code that ignores these warnings may work fine most of the time but fail in unusual ways that are hard to reproduce.  <br /><br /><u>Guidelines for development: </u><br /><br /><ul><li>Understand when the APIs and operations you use might have undefined behavior and prevent those conditions. </li><li>Do not depend on data structure iteration order unless it is guaranteed. It is a common mistake to depend on the ordering of <a href="http://en.wikipedia.org/wiki/Set_(computer_science)">sets</a> or <a href="http://en.wikipedia.org/wiki/Associative_array">associative arrays</a>. </li></ul><br /><br /><b><span>Log the details for errors or test failures </span></b><br /><br />Issues described in this article can be easier to reproduce and debug when the logs contain enough detail to understand the conditions that led to an error. <br /><br /><u>Guidelines for development: </u><br /><br /><ul><li>Follow <a href="http://googletesting.blogspot.com/2013/06/optimal-logging.html">good logging practices</a>, especially in your error handling code. </li><li>If logs are stored on a user&#8217;s machine, create an easy way for them to provide you the logs. </li></ul><br /><u>Guidelines for testing: </u><br /><br /><ul><li>Save your test logs for potential analysis later. </li></ul><br /><br /><b><span>Anything to add? </span></b><br /><br />Have I missed any important guidelines for minimizing these bugs? What is your favorite hard-to-reproduce bug that you discovered and resolved? <br /><br />]]></description>
				<content:encoded><![CDATA[<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-W_7cqFXE2DA/Uu_ksr9HQOI/AAAAAAAAAFM/63eqQLF0cR8/s1600/cannot-repro.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-W_7cqFXE2DA/Uu_ksr9HQOI/AAAAAAAAAFM/63eqQLF0cR8/s1600/cannot-repro.png" height="307" width="320" /></a></div><br /><br /><i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><br />Unreproducible bugs are the bane of my existence. Far too often, I find a bug, report it, and hear back that it’s not a bug because it can’t be reproduced. Of course, the bug is still there, waiting to prey on its next victim. These types of bugs can be very expensive due to increased investigation time and overall lifetime. They can also have a damaging effect on product perception when users reporting these bugs are effectively ignored. We should be doing more to prevent them. In this article, I’ll go over some obvious, and maybe not so obvious, development/testing guidelines that can reduce the likelihood of these bugs from occurring. <br /><br /><br /><b><span style="color: blue;">Avoid and test for race conditions, deadlocks, timing issues, memory corruption, uninitialized memory access, memory leaks, and resource issues </span></b><br /><br />I am lumping together many bug types in this section, but they are all related somewhat by how we test for them and how disproportionately hard they are to reproduce and debug. The root cause and effect can be separated by milliseconds or hours, and stack traces might be nonexistent or misleading. A system may fail in strange ways when exposed to unusual traffic spikes or insufficient resources. Race conditions and deadlocks may only be discovered during unique traffic patterns or resource configurations. Timing issues may only be noticed when many components are integrated and their performance parameters and failure/retry/timeout delays create a chaotic system. Memory corruption or uninitialized memory access may go unnoticed for a large percentage of calls but become fatal for rare states. Memory leaks may be negligible unless the system is exposed to load for an extended period of time. <br /><br /><u>Guidelines for development: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Simplify your synchronization logic. If it’s too hard to understand, it will be difficult to reproduce and debug complex concurrency problems. </li><li>Always obtain locks in the same order. This is a tried-and-true guideline to avoid deadlocks, but I still see code that breaks it periodically. Define an order for obtaining multiple locks and never change that order.  </li><li>Don’t optimize by creating many fine-grained locks, unless you have verified that they are needed. Extra locks increase concurrency complexity. </li><li>Avoid shared memory, unless you truly need it. Shared memory access is very easy to get wrong, and the bugs may be quite difficult to reproduce. </li></ul><br /><u>Guidelines for testing: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li><a href="http://en.wikipedia.org/wiki/Stress_testing">Stress test</a> your system regularly. You don't want to be surprised by unexpected failures when your system is under heavy load.  </li><li>Test timeouts. Create tests that mock/fake dependencies to test timeout code. If your timeout code does something bad, it may cause a bug that only occurs under certain system conditions. </li><li>Test with debug and optimized builds. You may find that a well behaved debug build works fine, but the system fails in strange ways once optimized. </li><li>Test under constrained resources. Try reducing the number of data centers, machines, processes, threads, available disk space, or available memory. Also try simulating reduced network bandwidth. </li><li>Test for longevity. Some bugs require a long period of time to reveal themselves. For example, persistent data may become corrupt over time. </li><li>Use dynamic analysis tools like <a href="http://en.wikipedia.org/wiki/Memory_debugger">memory debuggers</a>, <a href="https://code.google.com/p/address-sanitizer/">ASan</a>, <a href="https://code.google.com/p/thread-sanitizer/">TSan</a>, and <a href="https://code.google.com/p/memory-sanitizer/wiki/MemorySanitizer">MSan</a> regularly. They can help identify many categories of unreproducible memory/threading issues. </li></ul><br /><br /><b><span style="color: blue;">Enforce preconditions </span></b><br /><br />I’ve seen many well-meaning functions with a high tolerance for bad input. For example, consider this function: <br /><br /><pre style="background: #000000; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: white; overflow: auto; padding: 10px;"><span style="color: #76d6ff;">void</span> ScheduleEvent(<span style="color: #76d6ff;">int</span> timeDurationMilliseconds) {<br />  <span style="color: #76d6ff;">if</span> (timeDurationMilliseconds &lt;= 0) {<br />    timeDurationMilliseconds = 1;<br />  }<br />  ...<br />}<br /></pre><br />This function is trying to help the calling code by adjusting the input to an acceptable value, but it may be doing damage by masking a bug. The calling code may be experiencing any number of problems described in this article, and passing garbage to this function will always work fine. The more functions that are written with this level of tolerance, the harder it is to trace back to the root cause, and the more likely it becomes that the end user will see garbage. Enforcing preconditions, for instance by using asserts, may actually cause a higher number of failures for new systems, but as systems mature, and many minor/major problems are identified early on, these checks can help improve long-term reliability. <br /><br /><u>Guidelines for development: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Enforce preconditions in your functions unless you have a good reason not to. </li></ul><br /><br /><b><span style="color: blue;">Use defensive programming </span></b><br /><br /><a href="http://en.wikipedia.org/wiki/Defensive_programming">Defensive programming</a> is another tried-and-true technique that is great at minimizing unreproducible bugs. If your code calls a dependency to do something, and that dependency quietly fails or returns garbage, how does your code handle it? You could test for situations like this via mocking or faking, but it’s even better to have your production code do sanity checking on its dependencies. For example: <br /><br /><pre style="background: #000000; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: white; overflow: auto; padding: 10px;"><span style="color: #76d6ff;">double</span> GetMonthlyLoanPayment() {<br />  <span style="color: #76d6ff;">double</span> rate = GetTodaysInterestRateFromExternalSystem();<br />  <span style="color: #76d6ff;">if</span> (rate &lt; 0.001 || rate &gt; 0.5) {<br />    <span style="color: #76d6ff;">throw</span> BadInterestRate(rate);<br />  }<br />  ...<br />}<br /></pre><br /><u>Guidelines for development: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>When possible, use defensive programming to verify the work of your dependencies with known risks of failure like user-provided data, I/O operations, and RPC calls. </li></ul><br /><u>Guidelines for testing: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Use <a href="http://en.wikipedia.org/wiki/Fuzz_testing">fuzz testing</a> to test your systems hardiness when enduring bad data. </li></ul><br /><br /><b><span style="color: blue;">Don’t hide all errors from the user </span></b><br /><br />There has been a trend in recent years toward hiding failures from users at all costs. In many cases, it makes perfect sense, but in some, we have gone overboard. Code that is very quiet and permissive during minor failures will allow an uninformed user to continue working in a failed state. The software may ultimately reach a fatal tipping point, and all the error conditions that led to failure have been ignored. If the user doesn’t know about the prior errors, they will not be able to report them, and you may not be able to reproduce them. <br /><br /><u>Guidelines for development: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Only hide errors from the user when you are certain that there is no impact to system state or the user. </li><li>Any error with impact to the user should be reported to the user with instructions for how to proceed. The information shown to the user, combined with data available to an engineer, should be enough to determine what went wrong. </li></ul><br /><br /><b><span style="color: blue;">Test error handling </span></b><br /><br />The most common sections of code to remain untested is error handling code. Don’t skip test coverage here. Bad error handling code can cause unreproducible bugs and create great risk if it does not handle fatal errors well. <br /><br /><u>Guidelines for testing: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Always test your error handling code. This is usually best accomplished by mocking or faking the component triggering the error. </li><li>It’s also a good practice to examine your log quality for all types of error handling.  </li></ul><br /><br /><b><span style="color: blue;">Check for duplicate keys </span></b><br /><br />If unique identifiers or data access keys are generated using random data or are not guaranteed to be globally unique, duplicate keys may cause data corruption or concurrency issues. Key duplication bugs are very difficult to reproduce. <br /><br /><u>Guidelines for development: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Try to guarantee uniqueness of all keys. </li><li>When not possible to guarantee unique keys, check if the recently generated key is already in use before using it. </li><li>Watch out for potential race conditions here and avoid them with synchronization. </li></ul><br /><br /><b><span style="color: blue;">Test for concurrent data access </span></b><br /><br />Some bugs only reveal themselves when multiple clients are reading/writing the same data. Your stress tests might be covering cases like these, but if they are not, you should have special tests for concurrent data access. Case like these are often unreproducible. For example, a user may have two instances of your app running against the same account, and they may not realize this when reporting a bug. <br /><br /><u>Guidelines for testing: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Always test for concurrent data access if it’s a feature of the system. Actually, even if it’s not a feature, verify that the system rejects it. Testing concurrency can be challenging. An approach that usually works for me is to create many worker threads that simultaneously attempt access and a master thread that monitors and verifies that some number of attempts were indeed concurrent, blocked or allowed as expected, and all were successful. Programmatic post-analysis of all attempts and changing system state may also be necessary to ensure that the system behaved well. </li></ul><br /><br /><b><span style="color: blue;">Steer clear of undefined behavior and non-deterministic access to data </span></b><br /><br />Some APIs and basic operations have warnings about <a href="http://en.wikipedia.org/wiki/Undefined_behavior">undefined behavior</a> when in certain states or provided with certain input. Similarly, some data structures do not guarantee an iteration order (example: <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Set.html#iterator()">Java’s Set</a>). Code that ignores these warnings may work fine most of the time but fail in unusual ways that are hard to reproduce.  <br /><br /><u>Guidelines for development: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Understand when the APIs and operations you use might have undefined behavior and prevent those conditions. </li><li>Do not depend on data structure iteration order unless it is guaranteed. It is a common mistake to depend on the ordering of <a href="http://en.wikipedia.org/wiki/Set_(computer_science)">sets</a> or <a href="http://en.wikipedia.org/wiki/Associative_array">associative arrays</a>. </li></ul><br /><br /><b><span style="color: blue;">Log the details for errors or test failures </span></b><br /><br />Issues described in this article can be easier to reproduce and debug when the logs contain enough detail to understand the conditions that led to an error. <br /><br /><u>Guidelines for development: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Follow <a href="http://googletesting.blogspot.com/2013/06/optimal-logging.html">good logging practices</a>, especially in your error handling code. </li><li>If logs are stored on a user’s machine, create an easy way for them to provide you the logs. </li></ul><br /><u>Guidelines for testing: </u><br /><br /><ul style="line-height: 1.5em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Save your test logs for potential analysis later. </li></ul><br /><br /><b><span style="color: blue;">Anything to add? </span></b><br /><br />Have I missed any important guidelines for minimizing these bugs? What is your favorite hard-to-reproduce bug that you discovered and resolved? <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/minimizing-unreproducible-bugs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>The Google Test and Development Environment &#8211; Pt. 3: Code, Build, and Test</title>
		<link>https://googledata.org/google-testing/the-google-test-and-development-environment-pt-3-code-build-and-test/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-google-test-and-development-environment-pt-3-code-build-and-test</link>
		<comments>https://googledata.org/google-testing/the-google-test-and-development-environment-pt-3-code-build-and-test/#comments</comments>
		<pubDate>Tue, 21 Jan 2014 19:03:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=0906cff3f77c93b9c52488b4a2c3e944</guid>
		<description><![CDATA[<i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><i><br /></i><i>This is the third in a series of articles about our work environment. See the <a href="http://googletesting.blogspot.com/2013/12/the-google-test-and-development.html">first</a>&#160;and <a href="http://googletesting.blogspot.com/2014/01/the-google-test-and-development.html">second</a>.</i><br /><br />I will never forget the awe I felt when running my first load test on my first project at Google. At previous companies I&#8217;ve worked, running a substantial load test took quite a bit of resource planning and preparation. At Google, I wrote less than 100 lines of code and was simulating tens of thousands of users after just minutes of prep work. The ease with which I was able to accomplish this is due to the impressive coding, building, and testing tools available at Google. In this article, I will discuss these tools and how they affect our test and development process. <br /><br /><b>Coding and building </b><br /><br />The tools and process for coding and building make it very easy to change production and test code. Even though we are a large company, we have managed to remain nimble. In a matter of minutes or hours, you can edit, test, review, and submit code to head. We have achieved this without sacrificing code quality by heavily investing in tools, testing, and infrastructure, and by prioritizing code reviews. <br /><br />Most production and test code is in a single, company-wide source control repository (open source projects like Chromium and Android have their own). There is a great deal of code sharing in the codebase, and this provides an incredible suite of code to build on. Most code is also in a single branch, so the majority of development is done at head. All code is also navigable, searchable, and editable from the browser. You&#8217;ll find code in numerous languages, but Java, C++, Python, Go, and JavaScript are the most common. <br /><br />Have a strong preference for editor? Engineers are free to choose from many IDEs and editors. The most common are Eclipse, Emacs, Vim, and IntelliJ, but many others are used as well. Engineers that are passionate about their prefered editors have built up and shared some truly impressive editor plugins/tooling over the years. <br /><br />Code reviews for all submissions are enforced via source control tooling. This also applies to test code, as our test code is held to the same standards as production code. The reviews are done via web-based code review tools that even include automatically generated test results. The process is very streamlined and efficient. Engineers can change and submit code in any part of the repository, but it must get reviewed by owners of the code being changed. This is great, because you can easily change code that your team depends on, rather than merely request a change to code you do not own. <br /><br />The <a href="http://google-engtools.blogspot.com/2011/08/build-in-cloud-how-build-system-works.html">Google build system</a> is used for building most code, and it is designed to work across many languages and platforms. It is remarkably simple to define and build targets. You won&#8217;t be needing that old Makefile book. <br /><br /><b>Running jobs and tests </b><br /><br />We have some pretty amazing machine and job management tools at Google. There is a generally available pool of machines in many data centers around the globe. The job management service makes it very easy to start jobs on arbitrary machines in any of these data centers. Failing machines are automatically removed from the pool, so tests rarely fail due to machine issues. With a little effort, you can also set up monitoring and pager alerting for your important jobs. <br /><br />From any machine you can spin up a massive number of tests and run them in parallel across many machines in the pool, via a single command. Each of these tests are run in a standard, isolated environment, so we rarely run into the &#8220;it works on my machine!&#8221; issue. <br /><br />Before code is submitted, <a href="http://googletesting.blogspot.com/2008/09/presubmit-and-performance.html">presubmit</a> tests can be run that will find all tests that depend transitively on the change and run them. You can also define presubmit rules that run checks on a code change and verify that tests were run before allowing submission. <br /><br />Once you&#8217;ve submitted test code, the build and test system automatically registers the test, and starts building/testing continuously. If the test starts failing, your team will get notification emails. You can also visit a test dashboard for your team and get details about test runs and test data. Monitoring the build/test status is made even easier with our build orbs designed and built by Googlers. These small devices will glow red if the build starts failing. Many teams have had fun customizing these orbs to various shapes, including a statue of liberty with a glowing torch. <br /><br /><div><a href="http://3.bp.blogspot.com/-il9jbjZdgxk/Ut7DeUdUIeI/AAAAAAAAAE8/J9FqDTO6DG0/s1600/liberty.png"><img border="0" src="http://3.bp.blogspot.com/-il9jbjZdgxk/Ut7DeUdUIeI/AAAAAAAAAE8/J9FqDTO6DG0/s1600/liberty.png" height="320" width="153"></a></div><div><i>Statue of LORBerty </i></div><br />Running larger integration and end-to-end tests takes a little more work, but we have some excellent tools to help with these tests as well: Integration test runners, hermetic environment creation, virtual machine service, web test frameworks, etc. <br /><br /><b>The impact </b><br /><br />So how do these tools actually affect our productivity? For starters, the code is easy to find, edit, review, and submit. Engineers are free to choose tools that make them most productive. Before and after submission, running small tests is trivial, and running large tests is relatively easy. Since tests are easy to create and run, it&#8217;s fairly simple to maintain a green build, which most teams do most of the time. This allows us to spend more time on real problems and less on the things that shouldn&#8217;t even be problems. It allows us to focus on creating rigorous tests. It dramatically accelerates the development process that can <a href="http://paulbuchheit.blogspot.com/2009/01/communicating-with-code.html">prototype Gmail in a day</a> and code/test/release service features on a daily schedule. And, of course, it lets us focus on the fun stuff. <br /><br /><b>Thoughts? </b><br /><br />We are interested to hear your thoughts on this topic. Google has the resources to build tools like this, but would small or medium size companies benefit from a similar investment in its infrastructure? Did Google create the infrastructure or did the infrastructure create Google? <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><i><br /></i><i>This is the third in a series of articles about our work environment. See the <a href="http://googletesting.blogspot.com/2013/12/the-google-test-and-development.html">first</a>&nbsp;and <a href="http://googletesting.blogspot.com/2014/01/the-google-test-and-development.html">second</a>.</i><br /><br />I will never forget the awe I felt when running my first load test on my first project at Google. At previous companies I’ve worked, running a substantial load test took quite a bit of resource planning and preparation. At Google, I wrote less than 100 lines of code and was simulating tens of thousands of users after just minutes of prep work. The ease with which I was able to accomplish this is due to the impressive coding, building, and testing tools available at Google. In this article, I will discuss these tools and how they affect our test and development process. <br /><br /><b>Coding and building </b><br /><br />The tools and process for coding and building make it very easy to change production and test code. Even though we are a large company, we have managed to remain nimble. In a matter of minutes or hours, you can edit, test, review, and submit code to head. We have achieved this without sacrificing code quality by heavily investing in tools, testing, and infrastructure, and by prioritizing code reviews. <br /><br />Most production and test code is in a single, company-wide source control repository (open source projects like Chromium and Android have their own). There is a great deal of code sharing in the codebase, and this provides an incredible suite of code to build on. Most code is also in a single branch, so the majority of development is done at head. All code is also navigable, searchable, and editable from the browser. You’ll find code in numerous languages, but Java, C++, Python, Go, and JavaScript are the most common. <br /><br />Have a strong preference for editor? Engineers are free to choose from many IDEs and editors. The most common are Eclipse, Emacs, Vim, and IntelliJ, but many others are used as well. Engineers that are passionate about their prefered editors have built up and shared some truly impressive editor plugins/tooling over the years. <br /><br />Code reviews for all submissions are enforced via source control tooling. This also applies to test code, as our test code is held to the same standards as production code. The reviews are done via web-based code review tools that even include automatically generated test results. The process is very streamlined and efficient. Engineers can change and submit code in any part of the repository, but it must get reviewed by owners of the code being changed. This is great, because you can easily change code that your team depends on, rather than merely request a change to code you do not own. <br /><br />The <a href="http://google-engtools.blogspot.com/2011/08/build-in-cloud-how-build-system-works.html">Google build system</a> is used for building most code, and it is designed to work across many languages and platforms. It is remarkably simple to define and build targets. You won’t be needing that old Makefile book. <br /><br /><b>Running jobs and tests </b><br /><br />We have some pretty amazing machine and job management tools at Google. There is a generally available pool of machines in many data centers around the globe. The job management service makes it very easy to start jobs on arbitrary machines in any of these data centers. Failing machines are automatically removed from the pool, so tests rarely fail due to machine issues. With a little effort, you can also set up monitoring and pager alerting for your important jobs. <br /><br />From any machine you can spin up a massive number of tests and run them in parallel across many machines in the pool, via a single command. Each of these tests are run in a standard, isolated environment, so we rarely run into the “it works on my machine!” issue. <br /><br />Before code is submitted, <a href="http://googletesting.blogspot.com/2008/09/presubmit-and-performance.html">presubmit</a> tests can be run that will find all tests that depend transitively on the change and run them. You can also define presubmit rules that run checks on a code change and verify that tests were run before allowing submission. <br /><br />Once you’ve submitted test code, the build and test system automatically registers the test, and starts building/testing continuously. If the test starts failing, your team will get notification emails. You can also visit a test dashboard for your team and get details about test runs and test data. Monitoring the build/test status is made even easier with our build orbs designed and built by Googlers. These small devices will glow red if the build starts failing. Many teams have had fun customizing these orbs to various shapes, including a statue of liberty with a glowing torch. <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-il9jbjZdgxk/Ut7DeUdUIeI/AAAAAAAAAE8/J9FqDTO6DG0/s1600/liberty.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-il9jbjZdgxk/Ut7DeUdUIeI/AAAAAAAAAE8/J9FqDTO6DG0/s1600/liberty.png" height="320" width="153" /></a></div><div style="text-align: center;"><i>Statue of LORBerty </i></div><br />Running larger integration and end-to-end tests takes a little more work, but we have some excellent tools to help with these tests as well: Integration test runners, hermetic environment creation, virtual machine service, web test frameworks, etc. <br /><br /><b>The impact </b><br /><br />So how do these tools actually affect our productivity? For starters, the code is easy to find, edit, review, and submit. Engineers are free to choose tools that make them most productive. Before and after submission, running small tests is trivial, and running large tests is relatively easy. Since tests are easy to create and run, it’s fairly simple to maintain a green build, which most teams do most of the time. This allows us to spend more time on real problems and less on the things that shouldn’t even be problems. It allows us to focus on creating rigorous tests. It dramatically accelerates the development process that can <a href="http://paulbuchheit.blogspot.com/2009/01/communicating-with-code.html">prototype Gmail in a day</a> and code/test/release service features on a daily schedule. And, of course, it lets us focus on the fun stuff. <br /><br /><b>Thoughts? </b><br /><br />We are interested to hear your thoughts on this topic. Google has the resources to build tools like this, but would small or medium size companies benefit from a similar investment in its infrastructure? Did Google create the infrastructure or did the infrastructure create Google? <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/the-google-test-and-development-environment-pt-3-code-build-and-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>The Google Test and Development Environment &#8211; Pt. 2: Dogfooding and Office Software</title>
		<link>https://googledata.org/google-testing/the-google-test-and-development-environment-pt-2-dogfooding-and-office-software/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-google-test-and-development-environment-pt-2-dogfooding-and-office-software</link>
		<comments>https://googledata.org/google-testing/the-google-test-and-development-environment-pt-2-dogfooding-and-office-software/#comments</comments>
		<pubDate>Fri, 03 Jan 2014 18:41:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=d8c93f38838ac082e1528cff8738cefc</guid>
		<description><![CDATA[<i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><i><br /></i><i>This is the second in a series of articles about our work environment. See the <a href="http://googletesting.blogspot.com/2013/12/the-google-test-and-development.html">first</a>. </i><br /><br />There are few things as frustrating as getting hampered in your work by a bug in a product you depend on. What if it&#8217;s a product developed by your company? Do you report/fix the issue or just work around it and hope it&#8217;ll go away soon? In this article, I&#8217;ll cover how and why Google <a href="http://en.wikipedia.org/wiki/Eating_your_own_dog_food">dogfoods</a> its own products. <br /><br /><b>Dogfooding </b><br /><br />Google makes heavy use of its own products. We have a large ecosystem of development/office tools and use them for nearly everything we do. Because we use them on a daily basis, we can dogfood releases company-wide before launching to the public. These dogfood versions often have features unavailable to the public but may be less stable. Instability is exactly what you want in your tools, right? Or, would you rather that frustration be passed on to your company&#8217;s customers? Of course not! <br /><br />Dogfooding is an important part of our test process. Test teams do their best to find problems before dogfooding, but we all know that testing is never perfect. We often get dogfood bug reports for edge and corner cases not initially covered by testing. We also get many comments about overall product quality and usability. This internal feedback has, on many occasions, changed product design. <br /><br />Not surprisingly, test-focused engineers often have a lot to say during the dogfood phase. I don&#8217;t think there is a single public-facing product that I have not reported bugs on. I really appreciate the fact that I can provide feedback on so many products before release. <br /><br />Interested in helping to test Google products? Many of our products have feedback links built-in. Some also have Beta releases available. For example, you can start using <a href="https://www.google.com/intl/en/chrome/browser/beta.html">Chrome Beta</a> and help us file bugs. <br /><br /><b>Office software </b><br /><br />From system design documents, to test plans, to discussions about beer brewing techniques, our products are used internally. A company&#8217;s choice of office tools can have a big impact on productivity, and it is fortunate for Google that we have such a comprehensive suite. The tools have a consistently simple UI (no manual required), perform very well, encourage collaboration, and auto-save in the cloud. Now that I am used to these tools, I would certainly have a hard time going back to the tools of previous companies I have worked. I&#8217;m sure I would forget to click the save buttons for years to come. <br /><br />Examples of frequently used tools by engineers: <br /><ul><li><a href="http://www.google.com/drive/apps.html">Google Drive Apps</a> (Docs, Sheets, Slides, etc.) are used for design documents, test plans, project data, data analysis, presentations, and more.</li><li><a href="https://mail.google.com/intl/en/mail/help/about.html">Gmail</a> and <a href="https://www.google.com/hangouts/">Hangouts</a> are used for email and chat.</li><li><a href="https://support.google.com/calendar">Google Calendar</a> is used to schedule all meetings, reserve conference rooms, and setup video conferencing using Hangouts.</li><li><a href="https://maps.google.com/">Google Maps</a> is used to map office floors.</li><li><a href="https://support.google.com/groups">Google Groups</a> are used for email lists.</li><li><a href="https://support.google.com/sites">Google Sites</a> are used to host team pages, engineering docs, and more.</li><li><a href="https://cloud.google.com/products/app-engine">Google App Engine</a> hosts many corporate, development, and test apps.</li><li><a href="https://www.google.com/intl/en/chrome/browser">Chrome</a> is our primary browser on all platforms.</li><li><a href="https://support.google.com/plus">Google+</a> is used for organizing internal communities on topics such as food or C++, and for socializing.</li></ul><br /><b>Thoughts? </b><br /><br />We are interested to hear your thoughts on this topic. Do you dogfood your company&#8217;s products? Do your office tools help or hinder your productivity? What office software and tools do you find invaluable for your job? Could you use Google Docs/Sheets for large test plans? <br /><br /><div><a href="http://googletesting.blogspot.com/2014/01/the-google-test-and-development_21.html">(Continue to part 3)</a></div>]]></description>
				<content:encoded><![CDATA[<i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><i><br /></i><i>This is the second in a series of articles about our work environment. See the <a href="http://googletesting.blogspot.com/2013/12/the-google-test-and-development.html">first</a>. </i><br /><br />There are few things as frustrating as getting hampered in your work by a bug in a product you depend on. What if it’s a product developed by your company? Do you report/fix the issue or just work around it and hope it’ll go away soon? In this article, I’ll cover how and why Google <a href="http://en.wikipedia.org/wiki/Eating_your_own_dog_food">dogfoods</a> its own products. <br /><br /><b>Dogfooding </b><br /><br />Google makes heavy use of its own products. We have a large ecosystem of development/office tools and use them for nearly everything we do. Because we use them on a daily basis, we can dogfood releases company-wide before launching to the public. These dogfood versions often have features unavailable to the public but may be less stable. Instability is exactly what you want in your tools, right? Or, would you rather that frustration be passed on to your company’s customers? Of course not! <br /><br />Dogfooding is an important part of our test process. Test teams do their best to find problems before dogfooding, but we all know that testing is never perfect. We often get dogfood bug reports for edge and corner cases not initially covered by testing. We also get many comments about overall product quality and usability. This internal feedback has, on many occasions, changed product design. <br /><br />Not surprisingly, test-focused engineers often have a lot to say during the dogfood phase. I don’t think there is a single public-facing product that I have not reported bugs on. I really appreciate the fact that I can provide feedback on so many products before release. <br /><br />Interested in helping to test Google products? Many of our products have feedback links built-in. Some also have Beta releases available. For example, you can start using <a href="https://www.google.com/intl/en/chrome/browser/beta.html">Chrome Beta</a> and help us file bugs. <br /><br /><b>Office software </b><br /><br />From system design documents, to test plans, to discussions about beer brewing techniques, our products are used internally. A company’s choice of office tools can have a big impact on productivity, and it is fortunate for Google that we have such a comprehensive suite. The tools have a consistently simple UI (no manual required), perform very well, encourage collaboration, and auto-save in the cloud. Now that I am used to these tools, I would certainly have a hard time going back to the tools of previous companies I have worked. I’m sure I would forget to click the save buttons for years to come. <br /><br />Examples of frequently used tools by engineers: <br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li><a href="http://www.google.com/drive/apps.html">Google Drive Apps</a> (Docs, Sheets, Slides, etc.) are used for design documents, test plans, project data, data analysis, presentations, and more.</li><li><a href="https://mail.google.com/intl/en/mail/help/about.html">Gmail</a> and <a href="https://www.google.com/hangouts/">Hangouts</a> are used for email and chat.</li><li><a href="https://support.google.com/calendar">Google Calendar</a> is used to schedule all meetings, reserve conference rooms, and setup video conferencing using Hangouts.</li><li><a href="https://maps.google.com/">Google Maps</a> is used to map office floors.</li><li><a href="https://support.google.com/groups">Google Groups</a> are used for email lists.</li><li><a href="https://support.google.com/sites">Google Sites</a> are used to host team pages, engineering docs, and more.</li><li><a href="https://cloud.google.com/products/app-engine">Google App Engine</a> hosts many corporate, development, and test apps.</li><li><a href="https://www.google.com/intl/en/chrome/browser">Chrome</a> is our primary browser on all platforms.</li><li><a href="https://support.google.com/plus">Google+</a> is used for organizing internal communities on topics such as food or C++, and for socializing.</li></ul><br /><b>Thoughts? </b><br /><br />We are interested to hear your thoughts on this topic. Do you dogfood your company’s products? Do your office tools help or hinder your productivity? What office software and tools do you find invaluable for your job? Could you use Google Docs/Sheets for large test plans? <br /><br /><div style="text-align: center;"><a href="http://googletesting.blogspot.com/2014/01/the-google-test-and-development_21.html">(Continue to part 3)</a></div>]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/the-google-test-and-development-environment-pt-2-dogfooding-and-office-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>The Google Test and Development Environment &#8211; Pt. 1: Office and Equipment</title>
		<link>https://googledata.org/google-testing/the-google-test-and-development-environment-pt-1-office-and-equipment/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-google-test-and-development-environment-pt-1-office-and-equipment</link>
		<comments>https://googledata.org/google-testing/the-google-test-and-development-environment-pt-1-office-and-equipment/#comments</comments>
		<pubDate>Fri, 20 Dec 2013 19:58:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=f348d63257320d45443e3e97c53db299</guid>
		<description><![CDATA[<i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><br />When conducting interviews, I often get questions about our workspace and engineering environment. What IDEs do you use? What programming languages are most common? What kind of tools do you have for testing? What does the workspace look like? <br /><br />Google is a company that is constantly pushing to improve itself. Just like software development itself, most environment improvements happen via a bottom-up approach. All engineers are responsible for fine-tuning, experimenting with, and improving our process, with a goal of eliminating barriers to creating products that amaze.  <br /><br />Office space and engineering equipment can have a considerable impact on productivity. I&#8217;ll focus on these areas of our work environment in this first article of a series on the topic. <br /><br /><b>Office layout </b><br /><br />Google is a highly collaborative workplace, so the open floor plan suits our engineering process. Project teams composed of Software Engineers (SWEs), Software Engineers in Test (SETs), and Test Engineers (TEs) all sit near each other or in large rooms together. The test-focused engineers are involved in every step of the development process, so it&#8217;s critical for them to sit with the product developers. This keeps the lines of communication open.  <br /><br /><div><a href="http://1.bp.blogspot.com/-i9JDR9-1_0Y/UrSew1LuOTI/AAAAAAAAAEU/4d0DnlNkANM/s1600/google-munich.jpg"><img border="0" src="http://1.bp.blogspot.com/-i9JDR9-1_0Y/UrSew1LuOTI/AAAAAAAAAEU/4d0DnlNkANM/s400/google-munich.jpg" height="265" width="400"></a></div><div><i>Google Munich </i></div><br />The office space is far from rigid, and teams often rearrange desks to suit their preferences. The facilities team recently finished renovating a new floor in the New York City office, and after a day of engineering debates on optimal arrangements and white board diagrams, the floor was completely transformed. <br /><br />Besides the main office areas, there are lounge areas to which Googlers go for a change of scenery or a little peace and quiet. If you are trying to avoid becoming a casualty of The Great Foam Dart War, lounges are a great place to hide. <br /><br /><div><a href="http://4.bp.blogspot.com/-PU5Uno6oYWY/UrSe4rg-QtI/AAAAAAAAAEc/KNmnkb6Tt3c/s1600/dublin.jpg"><img border="0" src="http://4.bp.blogspot.com/-PU5Uno6oYWY/UrSe4rg-QtI/AAAAAAAAAEc/KNmnkb6Tt3c/s400/dublin.jpg" height="265" width="400"></a></div><div><i>Google Dublin </i></div><br /><b>Working with remote teams </b><br /><br />Google&#8217;s worldwide headquarters is in Mountain View, CA, but it&#8217;s a very global company, and our project teams are often distributed across multiple sites. To help keep teams well connected, most of our conference rooms have video conferencing equipment. We make frequent use of this equipment for team meetings, presentations, and quick chats. <br /><br /><div><a href="http://4.bp.blogspot.com/-Mtimvx4gLl8/UrSfDPmirCI/AAAAAAAAAEk/YqW83CQpC5o/s1600/boston.jpg"><img border="0" src="http://4.bp.blogspot.com/-Mtimvx4gLl8/UrSfDPmirCI/AAAAAAAAAEk/YqW83CQpC5o/s400/boston.jpg" height="298" width="400"></a></div><div><i>Google Boston </i></div><br /><b>What&#8217;s at your desk? </b><br /><br />All engineers get high-end machines and have easy access to data center machines for running large tasks. A new member on my team recently mentioned that his Google machine has 16 times the memory of the machine at his previous company. <br /><br />Most Google code runs on Linux, so the majority of development is done on Linux workstations. However, those that work on client code for Windows, OS X, or mobile, develop on relevant OSes. For displays, each engineer has a choice of either two 24 inch monitors or one 30 inch monitor. We also get our choice of laptop, picking from various models of Chromebook, MacBook, or Linux. These come in handy when going to meetings, lounges, or working remotely.  <br /><br /><div><a href="http://2.bp.blogspot.com/-f5ukeR3cgzI/UrSfH83SnJI/AAAAAAAAAEs/6SwfI6Ijfxo/s1600/zurich.jpg"><img border="0" src="http://2.bp.blogspot.com/-f5ukeR3cgzI/UrSfH83SnJI/AAAAAAAAAEs/6SwfI6Ijfxo/s400/zurich.jpg" height="266" width="400"></a></div><div><i>Google Zurich </i></div><br /><b>Thoughts? </b><br /><br />We are interested to hear your thoughts on this topic. Do you prefer an open-office layout, cubicles, or private offices? Should test teams be embedded with development teams, or should they operate separately? Do the benefits of offering engineers high-end equipment outweigh the costs? <br /><br /><div><a href="http://googletesting.blogspot.com/2014/01/the-google-test-and-development.html">(Continue to part 2)</a></div><div><br /></div>]]></description>
				<content:encoded><![CDATA[<i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><br />When conducting interviews, I often get questions about our workspace and engineering environment. What IDEs do you use? What programming languages are most common? What kind of tools do you have for testing? What does the workspace look like? <br /><br />Google is a company that is constantly pushing to improve itself. Just like software development itself, most environment improvements happen via a bottom-up approach. All engineers are responsible for fine-tuning, experimenting with, and improving our process, with a goal of eliminating barriers to creating products that amaze.  <br /><br />Office space and engineering equipment can have a considerable impact on productivity. I’ll focus on these areas of our work environment in this first article of a series on the topic. <br /><br /><b>Office layout </b><br /><br />Google is a highly collaborative workplace, so the open floor plan suits our engineering process. Project teams composed of Software Engineers (SWEs), Software Engineers in Test (SETs), and Test Engineers (TEs) all sit near each other or in large rooms together. The test-focused engineers are involved in every step of the development process, so it’s critical for them to sit with the product developers. This keeps the lines of communication open.  <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-i9JDR9-1_0Y/UrSew1LuOTI/AAAAAAAAAEU/4d0DnlNkANM/s1600/google-munich.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-i9JDR9-1_0Y/UrSew1LuOTI/AAAAAAAAAEU/4d0DnlNkANM/s400/google-munich.jpg" height="265" width="400" /></a></div><div style="text-align: center;"><i>Google Munich </i></div><br />The office space is far from rigid, and teams often rearrange desks to suit their preferences. The facilities team recently finished renovating a new floor in the New York City office, and after a day of engineering debates on optimal arrangements and white board diagrams, the floor was completely transformed. <br /><br />Besides the main office areas, there are lounge areas to which Googlers go for a change of scenery or a little peace and quiet. If you are trying to avoid becoming a casualty of The Great Foam Dart War, lounges are a great place to hide. <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-PU5Uno6oYWY/UrSe4rg-QtI/AAAAAAAAAEc/KNmnkb6Tt3c/s1600/dublin.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-PU5Uno6oYWY/UrSe4rg-QtI/AAAAAAAAAEc/KNmnkb6Tt3c/s400/dublin.jpg" height="265" width="400" /></a></div><div style="text-align: center;"><i>Google Dublin </i></div><br /><b>Working with remote teams </b><br /><br />Google’s worldwide headquarters is in Mountain View, CA, but it’s a very global company, and our project teams are often distributed across multiple sites. To help keep teams well connected, most of our conference rooms have video conferencing equipment. We make frequent use of this equipment for team meetings, presentations, and quick chats. <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-Mtimvx4gLl8/UrSfDPmirCI/AAAAAAAAAEk/YqW83CQpC5o/s1600/boston.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-Mtimvx4gLl8/UrSfDPmirCI/AAAAAAAAAEk/YqW83CQpC5o/s400/boston.jpg" height="298" width="400" /></a></div><div style="text-align: center;"><i>Google Boston </i></div><br /><b>What’s at your desk? </b><br /><br />All engineers get high-end machines and have easy access to data center machines for running large tasks. A new member on my team recently mentioned that his Google machine has 16 times the memory of the machine at his previous company. <br /><br />Most Google code runs on Linux, so the majority of development is done on Linux workstations. However, those that work on client code for Windows, OS X, or mobile, develop on relevant OSes. For displays, each engineer has a choice of either two 24 inch monitors or one 30 inch monitor. We also get our choice of laptop, picking from various models of Chromebook, MacBook, or Linux. These come in handy when going to meetings, lounges, or working remotely.  <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-f5ukeR3cgzI/UrSfH83SnJI/AAAAAAAAAEs/6SwfI6Ijfxo/s1600/zurich.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-f5ukeR3cgzI/UrSfH83SnJI/AAAAAAAAAEs/6SwfI6Ijfxo/s400/zurich.jpg" height="266" width="400" /></a></div><div style="text-align: center;"><i>Google Zurich </i></div><br /><b>Thoughts? </b><br /><br />We are interested to hear your thoughts on this topic. Do you prefer an open-office layout, cubicles, or private offices? Should test teams be embedded with development teams, or should they operate separately? Do the benefits of offering engineers high-end equipment outweigh the costs? <br /><br /><div style="text-align: center;"><a href="http://googletesting.blogspot.com/2014/01/the-google-test-and-development.html">(Continue to part 2)</a></div><div style="text-align: center;"><br /></div>]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/the-google-test-and-development-environment-pt-1-office-and-equipment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>WebRTC Audio Quality Testing</title>
		<link>https://googledata.org/google-testing/webrtc-audio-quality-testing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=webrtc-audio-quality-testing</link>
		<comments>https://googledata.org/google-testing/webrtc-audio-quality-testing/#comments</comments>
		<pubDate>Fri, 08 Nov 2013 18:47:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=c870033d250d027502bcc2b0b5bde1c8</guid>
		<description><![CDATA[<i>by Patrik H&#246;glund </i><br /><br />The <a href="http://www.webrtc.org/">WebRTC project</a> is all about enabling peer-to-peer video, voice and data transfer in the browser. To give our users the best possible experience we need to adapt the quality of the media to the bandwidth and processing power we have available. Our users encounter a wide variety of network conditions and run on a variety of devices, from powerful desktop machines with a wired broadband connection to laptops on WiFi to mobile phones on spotty 3G networks. <br /><br />We want to ensure good quality for all these use cases in our implementation in Chrome. To some extent we can do this with manual testing, but the breakneck pace of Chrome development makes it very hard to keep up (several hundred patches land every day)! Therefore, we'd like to test the quality of our video and voice transfer with an automated test. Ideally, we&#8217;d like to test for the most common network scenarios our users encounter, but to start we chose to implement a test where we have plenty of CPU and bandwidth. This article covers how we built such a test. <br /><br /><span><b>Quality Metrics </b></span><br />First, we must define what we want to measure. For instance, the <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc&#38;q=chrome_webrtc_vi&#38;sq=package:chromium">WebRTC video quality test</a> uses <a href="http://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio">peak signal-to-noise ratio</a> and <a href="http://en.wikipedia.org/wiki/Structural_similarity">structural similarity</a> to measure the quality of the video (or to be more precise, how much the output video differs from the input video; see <a href="http://www.youtube.com/watch?v=IbLNm3LsMaw&#38;list=SPSIUOFhnxEiCODb8XQB-RUQ0RGNZ2yW7d">this GTAC 13 talk</a> for more details). The quality of the user experience is a subjective thing though. Arguably, one probably needs dozens of different metrics to really ensure a good user experience. For video, we would have to (at the very least) have some measure for frame rate and resolution besides correctness. To have the system send somewhat correct video frames seemed the most important though, which is why we chose the above metrics. <br /><br />For this test we wanted to start with a similar correctness metric, but for audio. It turns out there's an algorithm called <a href="http://en.wikipedia.org/wiki/PESQ">Perceptual Evaluation of Speech Quality</a> (PESQ) which analyzes two audio files and tell you how similar they are, while taking into account how the human ear works (so it ignores differences a normal person would not hear anyway). That's great, since we want our metrics to measure the user experience as much as possible.  There are many aspects of voice transfer you could measure, such as latency (which is really important for voice calls), but for now we'll focus on measuring how much a voice audio stream gets distorted by the transfer. <br /><br /><span><b>Feeding Audio Into WebRTC </b></span><br />In the WebRTC case we already <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/media/chrome_webrtc_browsertest.cc&#38;sq=package:chromium">had a test</a> which would launch a Chrome browser, open two tabs, get the tabs talking to each other through a signaling server and set up a call on a single machine. Then we just needed to figure out how to feed a reference audio file into a WebRTC call and record what comes out on the other end. This part was actually harder than it sounds. The main WebRTC use case is that the web page acquires the user's mic through <a href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html">getUserMedia</a>, sets up a PeerConnection with some remote peer and sends the audio from the mic through the connection to the peer where it is played in the peer's audio output device.  <br /><br /><div><a href="http://4.bp.blogspot.com/-vYo0ghEwlHk/Un0uYrQ13WI/AAAAAAAAAD4/NBy_CaccBYk/s1600/img1.png"><img border="0" height="316" src="http://4.bp.blogspot.com/-vYo0ghEwlHk/Un0uYrQ13WI/AAAAAAAAAD4/NBy_CaccBYk/s640/img1.png" width="640"></a></div><br /><br /><div><i>WebRTC calls transmit voice, video and data peer-to-peer, over the Internet. </i></div><br />But since this is an automated test, of course we could not have someone speak in a microphone every time the test runs; we had to feed in a known input file, so we had something to compare the recorded output audio against.  <br /><br />Could we duct-tape a small stereo to the mic and play our audio file on the stereo? That's not very maintainable or reliable, not to mention annoying for anyone in the vicinity. What about some kind of fake device driver which makes a microphone-like device appear on the device level? The problem with that is that it's hard to control a driver from the userspace test program. Also, the test will be more complex and flaky, and the driver interaction will not be portable.<a href="http://googletesting.blogspot.com/#foot1"><sup>[1]</sup></a><br /><br />Instead, we chose to sidestep this problem. We used a solution where we load an audio file with <a href="https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html">WebAudio</a> and play that straight into the peer connection through the <a href="https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/webrtc-integration.html">WebAudio-PeerConnection integration</a>. That way we start the playing of the file from the same renderer process as the call itself, which made it a lot easier to time the start and end of the file. We still needed to be careful to avoid playing the file too early or too late, so we don't clip the audio at the start or end - that would destroy our PESQ scores! - but it turned out to be a workable approach.<a href="http://googletesting.blogspot.com/#foot2"><sup>[2]</sup></a><br /><br /><span><b>Recording the Output </b></span><br />Alright, so now we could get a WebRTC call set up with a known audio file with decent control of when the file starts playing. Now we had to record the output. There are a number of possible solutions. The most end-to-end way is to straight up record what the system sends to default audio out (like speakers or headphones). Alternatively, we could write a hook in our application to dump our audio as late as possible, like when we're just about to send it to the sound card. <br /><br />We went with the former. Our colleagues in the Chrome video stack team in Kirkland had already found  that it's possible to configure a Windows or Linux machine to send the system's audio output (i.e. what plays on the speakers) to a virtual recording device. If we make that virtual recording device the default one, simply invoking SoundRecorder.exe and arecord respectively will record what the system is playing out.  <br /><br />They found this works well if one also uses the <a href="http://sox.sourceforge.net/">sox</a> utility to eliminate silence around the actual audio content (recall we had some safety margins at both ends to ensure we record the whole input file as playing through the WebRTC call). We adopted the same approach, since it records what the user would hear, and yet uses only standard tools. This means we don't have to install additional software on the myriad machines that will run this test.<a href="http://googletesting.blogspot.com/#foot3"><sup>[3]</sup></a><br /><br /><span><b>Analyzing Audio </b></span><br />The only remaining step was to compare the silence-eliminated recording with the input file. When we first did this, we got a really bad score (like 2.0 out of 5.0, which means PESQ thinks it&#8217;s barely legible). This didn't seem to make sense, since both the input and recording sounded very similar. Turns out we didn&#8217;t think about the following: <br /><br /><ul><li>We were comparing a full-band (24 kHz) input file to a wide-band (8 kHz) result (although both files were sampled at 48 kHz). This essentially amounted to a low pass filtering of the result file. </li><li>Both files were in stereo, but PESQ is only mono-aware. </li><li>The files were 32-bit, but the PESQ implementation is designed for 16 bits. </li></ul><br />As you can see, it&#8217;s important to pay attention to what format arecord and SoundRecorder.exe records in, and make sure the input file is recorded in the same way. After correcting the input file and &#8220;rebasing&#8221;, we got the score up to about 4.0.<a href="http://googletesting.blogspot.com/#foot4"><sup>[4]</sup></a><br /><br />Thus, we ended up with an automated test that runs continously on the torrent of Chrome change lists and protects WebRTC's ability to transmit sound. You can see the <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc&#38;q=chrome_webrtc_a&#38;sq=package:chromium">finished code here</a>. With automated tests and cleverly chosen metrics you can protect against most regressions a user would notice. If your product includes video and audio handling, such a test is a great addition to your testing mix.  <br /><br /><div><a href="http://3.bp.blogspot.com/-pYtwelNAxwE/Un0vxiP2SdI/AAAAAAAAAEE/7Ta3KOYspd0/s1600/img2.png"><img border="0" src="http://3.bp.blogspot.com/-pYtwelNAxwE/Un0vxiP2SdI/AAAAAAAAAEE/7Ta3KOYspd0/s1600/img2.png"></a></div><br /><div><i>How the components of the test fit together. </i></div><br /><span><b>Future work </b></span><br /><br /><ul><li>It might be possible to write a Chrome extension which dumps the audio from Chrome to a file. That way we get a simpler-to-maintain and portable solution. It would be less end-to-end but more than worth it due to the simplified maintenance and setup. Also, the recording tools we use are not perfect and add some distortion, which makes the score less accurate. </li><li>There are other algorithms than PESQ to consider - for instance, <a href="http://en.wikipedia.org/wiki/POLQA">POLQA</a> is the successor to PESQ and is better at analyzing high-bandwidth audio signals. </li><li>We are working on a solution which will run this test under simulated network conditions. Simulated networks combined with this test is a really powerful way to test our behavior under various packet loss and delay scenarios and ensure we deliver a good experience to all our users, not just those with great broadband connections. Stay tuned for future articles on that topic! </li><li>Investigate feasibility of running this set-up on mobile devices. </li></ul><br /><br /><hr /><br /><sup>1</sup>It would be tolerable if the driver was just looping the input file, eliminating the need for the test to control the driver (i.e. the test doesn't have to tell the driver to start playing the file). This is actually what we do in the video quality test. It's a much better fit to take this approach on the video side since each recorded video frame is independent of the others. We can easily embed barcodes into each frame and evaluate them independently.  <br /><br />This seems much harder for audio. We could possibly do <a href="http://en.wikipedia.org/wiki/Audio_watermark">audio watermarking</a>, or we could embed a kind of start marker (for instance, using DTMF tones) in the first two seconds of the input file and play the real content after that, and then do some fancy audio processing on the receiving end to figure out the start and end of the input audio. We chose not to pursue this approach due to its complexity. <br /><br /><sup>2</sup>Unfortunately, this also means we will not test the capturer path (which handles microphones, etc in WebRTC). This is an example of the frequent tradeoffs one has to do when designing an end-to-end test. Often we have to trade end-to-endness (how close the test is to the user experience) with robustness and simplicity of a test. It's not worth it to cover 5% more of the code if the test become unreliable or radically more expensive to maintain. Another example: A WebRTC call will generally involve two peers on different devices separated by the real-world internet. Writing such a test and making it reliable would be extremely difficult, so we make the test single-machine and hope we catch most of the bugs anyway. <br /><br /><sup>3</sup>It's important to keep the continuous build setup simple and the build machines easy to configure - otherwise you will inevitably pay a heavy price in maintenance when you try to scale your testing up. <br /><br /><sup>4</sup>When sending audio over the internet, we have to compress it since lossless audio consumes way too much bandwidth. WebRTC audio generally sounds great, but there's still compression artifacts if you listen closely (and, in fact, the recording tools are not perfect and add some distorsion as well). Given that this test is more about detecting regressions than measuring some absolute notion of quality, we'd like to downplay those artifacts. As our Kirkland colleagues found, one of the ways to do that is to "rebase" the input file. That means we start with a pristine recording, feed that through the WebRTC call and record what comes out on the other end. After manually verifying the quality, we use that as our input file for the actual test. In our case, it pushed our PESQ score up from 3 to about 4 (out of 5), which gives us a bit more sensitivity to regressions. <br /><br />]]></description>
				<content:encoded><![CDATA[<i>by Patrik Höglund </i><br /><br />The <a href="http://www.webrtc.org/">WebRTC project</a> is all about enabling peer-to-peer video, voice and data transfer in the browser. To give our users the best possible experience we need to adapt the quality of the media to the bandwidth and processing power we have available. Our users encounter a wide variety of network conditions and run on a variety of devices, from powerful desktop machines with a wired broadband connection to laptops on WiFi to mobile phones on spotty 3G networks. <br /><br />We want to ensure good quality for all these use cases in our implementation in Chrome. To some extent we can do this with manual testing, but the breakneck pace of Chrome development makes it very hard to keep up (several hundred patches land every day)! Therefore, we'd like to test the quality of our video and voice transfer with an automated test. Ideally, we’d like to test for the most common network scenarios our users encounter, but to start we chose to implement a test where we have plenty of CPU and bandwidth. This article covers how we built such a test. <br /><br /><span style="font-size: large;"><b>Quality Metrics </b></span><br />First, we must define what we want to measure. For instance, the <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc&amp;q=chrome_webrtc_vi&amp;sq=package:chromium">WebRTC video quality test</a> uses <a href="http://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio">peak signal-to-noise ratio</a> and <a href="http://en.wikipedia.org/wiki/Structural_similarity">structural similarity</a> to measure the quality of the video (or to be more precise, how much the output video differs from the input video; see <a href="http://www.youtube.com/watch?v=IbLNm3LsMaw&amp;list=SPSIUOFhnxEiCODb8XQB-RUQ0RGNZ2yW7d">this GTAC 13 talk</a> for more details). The quality of the user experience is a subjective thing though. Arguably, one probably needs dozens of different metrics to really ensure a good user experience. For video, we would have to (at the very least) have some measure for frame rate and resolution besides correctness. To have the system send somewhat correct video frames seemed the most important though, which is why we chose the above metrics. <br /><br />For this test we wanted to start with a similar correctness metric, but for audio. It turns out there's an algorithm called <a href="http://en.wikipedia.org/wiki/PESQ">Perceptual Evaluation of Speech Quality</a> (PESQ) which analyzes two audio files and tell you how similar they are, while taking into account how the human ear works (so it ignores differences a normal person would not hear anyway). That's great, since we want our metrics to measure the user experience as much as possible.  There are many aspects of voice transfer you could measure, such as latency (which is really important for voice calls), but for now we'll focus on measuring how much a voice audio stream gets distorted by the transfer. <br /><br /><span style="font-size: large;"><b>Feeding Audio Into WebRTC </b></span><br />In the WebRTC case we already <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/media/chrome_webrtc_browsertest.cc&amp;sq=package:chromium">had a test</a> which would launch a Chrome browser, open two tabs, get the tabs talking to each other through a signaling server and set up a call on a single machine. Then we just needed to figure out how to feed a reference audio file into a WebRTC call and record what comes out on the other end. This part was actually harder than it sounds. The main WebRTC use case is that the web page acquires the user's mic through <a href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html">getUserMedia</a>, sets up a PeerConnection with some remote peer and sends the audio from the mic through the connection to the peer where it is played in the peer's audio output device.  <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-vYo0ghEwlHk/Un0uYrQ13WI/AAAAAAAAAD4/NBy_CaccBYk/s1600/img1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="http://4.bp.blogspot.com/-vYo0ghEwlHk/Un0uYrQ13WI/AAAAAAAAAD4/NBy_CaccBYk/s640/img1.png" width="640" /></a></div><br /><br /><div style="text-align: center;"><i>WebRTC calls transmit voice, video and data peer-to-peer, over the Internet. </i></div><br />But since this is an automated test, of course we could not have someone speak in a microphone every time the test runs; we had to feed in a known input file, so we had something to compare the recorded output audio against.  <br /><br />Could we duct-tape a small stereo to the mic and play our audio file on the stereo? That's not very maintainable or reliable, not to mention annoying for anyone in the vicinity. What about some kind of fake device driver which makes a microphone-like device appear on the device level? The problem with that is that it's hard to control a driver from the userspace test program. Also, the test will be more complex and flaky, and the driver interaction will not be portable.<a href="http://googletesting.blogspot.com/2013/11/webrtc-audio-quality-testing.html#foot1"><sup>[1]</sup></a><br /><br />Instead, we chose to sidestep this problem. We used a solution where we load an audio file with <a href="https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html">WebAudio</a> and play that straight into the peer connection through the <a href="https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/webrtc-integration.html">WebAudio-PeerConnection integration</a>. That way we start the playing of the file from the same renderer process as the call itself, which made it a lot easier to time the start and end of the file. We still needed to be careful to avoid playing the file too early or too late, so we don't clip the audio at the start or end - that would destroy our PESQ scores! - but it turned out to be a workable approach.<a href="http://googletesting.blogspot.com/2013/11/webrtc-audio-quality-testing.html#foot2"><sup>[2]</sup></a><br /><br /><span style="font-size: large;"><b>Recording the Output </b></span><br />Alright, so now we could get a WebRTC call set up with a known audio file with decent control of when the file starts playing. Now we had to record the output. There are a number of possible solutions. The most end-to-end way is to straight up record what the system sends to default audio out (like speakers or headphones). Alternatively, we could write a hook in our application to dump our audio as late as possible, like when we're just about to send it to the sound card. <br /><br />We went with the former. Our colleagues in the Chrome video stack team in Kirkland had already found  that it's possible to configure a Windows or Linux machine to send the system's audio output (i.e. what plays on the speakers) to a virtual recording device. If we make that virtual recording device the default one, simply invoking SoundRecorder.exe and arecord respectively will record what the system is playing out.  <br /><br />They found this works well if one also uses the <a href="http://sox.sourceforge.net/">sox</a> utility to eliminate silence around the actual audio content (recall we had some safety margins at both ends to ensure we record the whole input file as playing through the WebRTC call). We adopted the same approach, since it records what the user would hear, and yet uses only standard tools. This means we don't have to install additional software on the myriad machines that will run this test.<a href="http://googletesting.blogspot.com/2013/11/webrtc-audio-quality-testing.html#foot3"><sup>[3]</sup></a><br /><br /><span style="font-size: large;"><b>Analyzing Audio </b></span><br />The only remaining step was to compare the silence-eliminated recording with the input file. When we first did this, we got a really bad score (like 2.0 out of 5.0, which means PESQ thinks it’s barely legible). This didn't seem to make sense, since both the input and recording sounded very similar. Turns out we didn’t think about the following: <br /><br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>We were comparing a full-band (24 kHz) input file to a wide-band (8 kHz) result (although both files were sampled at 48 kHz). This essentially amounted to a low pass filtering of the result file. </li><li>Both files were in stereo, but PESQ is only mono-aware. </li><li>The files were 32-bit, but the PESQ implementation is designed for 16 bits. </li></ul><br />As you can see, it’s important to pay attention to what format arecord and SoundRecorder.exe records in, and make sure the input file is recorded in the same way. After correcting the input file and “rebasing”, we got the score up to about 4.0.<a href="http://googletesting.blogspot.com/2013/11/webrtc-audio-quality-testing.html#foot4"><sup>[4]</sup></a><br /><br />Thus, we ended up with an automated test that runs continously on the torrent of Chrome change lists and protects WebRTC's ability to transmit sound. You can see the <a href="https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc&amp;q=chrome_webrtc_a&amp;sq=package:chromium">finished code here</a>. With automated tests and cleverly chosen metrics you can protect against most regressions a user would notice. If your product includes video and audio handling, such a test is a great addition to your testing mix.  <br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-pYtwelNAxwE/Un0vxiP2SdI/AAAAAAAAAEE/7Ta3KOYspd0/s1600/img2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-pYtwelNAxwE/Un0vxiP2SdI/AAAAAAAAAEE/7Ta3KOYspd0/s1600/img2.png" /></a></div><br /><div style="text-align: center;"><i>How the components of the test fit together. </i></div><br /><span style="font-size: large;"><b>Future work </b></span><br /><br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>It might be possible to write a Chrome extension which dumps the audio from Chrome to a file. That way we get a simpler-to-maintain and portable solution. It would be less end-to-end but more than worth it due to the simplified maintenance and setup. Also, the recording tools we use are not perfect and add some distortion, which makes the score less accurate. </li><li>There are other algorithms than PESQ to consider - for instance, <a href="http://en.wikipedia.org/wiki/POLQA">POLQA</a> is the successor to PESQ and is better at analyzing high-bandwidth audio signals. </li><li>We are working on a solution which will run this test under simulated network conditions. Simulated networks combined with this test is a really powerful way to test our behavior under various packet loss and delay scenarios and ensure we deliver a good experience to all our users, not just those with great broadband connections. Stay tuned for future articles on that topic! </li><li>Investigate feasibility of running this set-up on mobile devices. </li></ul><br /><br /><hr /><br /><sup id="foot1">1</sup>It would be tolerable if the driver was just looping the input file, eliminating the need for the test to control the driver (i.e. the test doesn't have to tell the driver to start playing the file). This is actually what we do in the video quality test. It's a much better fit to take this approach on the video side since each recorded video frame is independent of the others. We can easily embed barcodes into each frame and evaluate them independently.  <br /><br />This seems much harder for audio. We could possibly do <a href="http://en.wikipedia.org/wiki/Audio_watermark">audio watermarking</a>, or we could embed a kind of start marker (for instance, using DTMF tones) in the first two seconds of the input file and play the real content after that, and then do some fancy audio processing on the receiving end to figure out the start and end of the input audio. We chose not to pursue this approach due to its complexity. <br /><br /><sup id="foot2">2</sup>Unfortunately, this also means we will not test the capturer path (which handles microphones, etc in WebRTC). This is an example of the frequent tradeoffs one has to do when designing an end-to-end test. Often we have to trade end-to-endness (how close the test is to the user experience) with robustness and simplicity of a test. It's not worth it to cover 5% more of the code if the test become unreliable or radically more expensive to maintain. Another example: A WebRTC call will generally involve two peers on different devices separated by the real-world internet. Writing such a test and making it reliable would be extremely difficult, so we make the test single-machine and hope we catch most of the bugs anyway. <br /><br /><sup id="foot3">3</sup>It's important to keep the continuous build setup simple and the build machines easy to configure - otherwise you will inevitably pay a heavy price in maintenance when you try to scale your testing up. <br /><br /><sup id="foot4">4</sup>When sending audio over the internet, we have to compress it since lossless audio consumes way too much bandwidth. WebRTC audio generally sounds great, but there's still compression artifacts if you listen closely (and, in fact, the recording tools are not perfect and add some distorsion as well). Given that this test is more about detecting regressions than measuring some absolute notion of quality, we'd like to downplay those artifacts. As our Kirkland colleagues found, one of the ways to do that is to "rebase" the input file. That means we start with a pristine recording, feed that through the WebRTC call and record what comes out on the other end. After manually verifying the quality, we use that as our input file for the actual test. In our case, it pushed our PESQ score up from 3 to about 4 (out of 5), which gives us a bit more sensitivity to regressions. <br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/webrtc-audio-quality-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Espresso for Android is here!</title>
		<link>https://googledata.org/google-testing/espresso-for-android-is-here/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=espresso-for-android-is-here</link>
		<comments>https://googledata.org/google-testing/espresso-for-android-is-here/#comments</comments>
		<pubDate>Fri, 18 Oct 2013 21:26:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>
		<category><![CDATA[android]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=dd78de03a255f68c0200bd23fdb348df</guid>
		<description><![CDATA[Cross-posted from the Android Developers Google+ PageEarlier this year, we presented Espresso at GTAC as a solution to the UI testing problem. Today we are announcing the launch of the developer preview for Espresso!The compelling thing about developin...]]></description>
				<content:encoded><![CDATA[<i>Cross-posted from the <a href="https://plus.sandbox.google.com/+AndroidDevelopers/posts">Android Developers Google+ Page</a></i><br /><br />Earlier this year, we presented Espresso at GTAC as a solution to the UI testing problem. Today we are announcing the launch of the developer preview for Espresso!<br /><br />The compelling thing about developing Espresso was making it easy and fun for developers to write reliable UI tests. Espresso has a small, predictable, and easy to learn API, which is still open for customization. But most importantly - Espresso removes the need to think about the complexity of multi-threaded testing. With Espresso, you can think procedurally and write concise, beautiful, and reliable Android UI tests quickly.<br /><br />Espresso is now being used by over 30 applications within Google (Drive, Maps and G+, just to name a few). Starting from today, Espresso will also be available to our great developer community. We hope you will also enjoy testing your applications with Espresso and looking forward to your feedback and contributions!<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-KD6xUPTsNjs/UmGmdurLO5I/AAAAAAAAADo/mjf_ZPao27c/s1600/logo.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-KD6xUPTsNjs/UmGmdurLO5I/AAAAAAAAADo/mjf_ZPao27c/s1600/logo.jpeg" /></a></div><br /><div style="text-align: center;">Android Test Kit: <a href="https://code.google.com/p/android-test-kit/">https://code.google.com/p/android-test-kit/</a></div><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/espresso-for-android-is-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>How the Google+ Team Tests Mobile Apps</title>
		<link>https://googledata.org/google-testing/how-the-google-team-tests-mobile-apps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-the-google-team-tests-mobile-apps</link>
		<comments>https://googledata.org/google-testing/how-the-google-team-tests-mobile-apps/#comments</comments>
		<pubDate>Fri, 30 Aug 2013 19:30:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=5e246733be683e3be8ffbfcaa87f9fe1</guid>
		<description><![CDATA[<i>by Eduardo Bravo Ortiz </i><br /><br />&#8220;Mobile first&#8221; is the motto these days for many companies. However, being able to test a mobile app in a meaningful way is very challenging. On the Google+ team we have had our share of trial and error that has led us to successful strategies for testing mobile applications on both iOS and Android. <br /><br /><span><b>General </b></span><br /><br /><ul><li>Understand the platform. Testing on Android is not the same as testing on iOS. The testing tools and frameworks available for each platform are significantly different. (e.g., Android uses Java while iOS uses Objective-C, UI layouts are built differently on each platform, UI testing frameworks also work very differently in both platforms.) </li><li>Stabilize your test suite and test environments. Flaky tests are worse than having no tests, because a flaky test pollutes your build health and decreases the credibility of your suite. </li><li>Break down testing into manageable pieces. There are too many complex pieces when testing on mobile (e.g., emulator/device state, actions triggered by the OS).  </li><li>Provide a <a href="http://googletesting.blogspot.com/2012/10/hermetic-servers.html">hermetic test</a> environment for your tests. Mobile UI tests are flaky by nature; don&#8217;t add more flakiness to them by having external dependencies. </li><li>Unit tests are the backbone of your mobile test strategy. Try to separate the app code logic from the UI as much as possible. This separation will make unit tests more granular and faster. </li></ul><br /><br /><b><span>Android Testing </span></b><br /><br /><b>Unit Tests </b><br />Separating UI code from code logic is especially hard in Android. For example, an Activity is expected to act as a controller and view at the same time; make sure you keep this in mind when writing unit tests. Another useful recommendation is to decouple unit tests from the Android emulator, this will remove the need to build an APK and install it and your tests will run much faster. <a href="http://pivotal.github.io/robolectric/">Robolectric</a> is a perfect tool for this; it stubs the implementation of the Android platform while running tests. <br /><br /><b>Hermetic UI Tests </b><br />A hermetic UI test typically runs as a test without network calls or external dependencies. Once the tests can run in a <a href="http://googletesting.blogspot.com/2012/10/hermetic-servers.html">hermetic environment</a>, a white box testing framework like <a href="http://www.youtube.com/watch?v=T7ugmCuNxDU">Espresso</a> can simulate user actions on the UI and is tightly coupled to the app code. Espresso will also synchronize your tests actions with events on the UI thread, reducing flakiness. More information on Espresso is coming in a future Google Testing Blog article. <br /><br /><div><b>Diagram: Non-Hermetic Flow vs. Hermetic Flow </b></div><div><a href="http://1.bp.blogspot.com/--yeG5Bgqzas/UiDv4W5iyWI/AAAAAAAAADQ/hwPYIYmaz9M/s1600/diagram1.png"><img border="0" height="199" src="http://1.bp.blogspot.com/--yeG5Bgqzas/UiDv4W5iyWI/AAAAAAAAADQ/hwPYIYmaz9M/s640/diagram1.png" width="640"></a></div><br /><br /><b>Monkey Tests </b><br />Monkey tests look for crashes and <a href="http://developer.android.com/training/articles/perf-anr.html">ANRs</a> by stressing your Android application. They exercise <a href="http://en.wikipedia.org/wiki/Pseudorandom_number_generator">pseudo-random</a> events like clicks or gestures on the app under test. Monkey test results are reproducible to a certain extent; timing and latency are not completely under your control and can cause a test failure. Re-running the same monkey test against the same configuration will often reproduce these failures, though. If you run them daily against different SDKs, they are very effective at catching bugs earlier in the development cycle of a new release. <br /><br /><b><span>iOS Testing </span></b><br /><br /><b>Unit Tests </b><br />Unit test frameworks like <a href="http://www.sente.ch/software/ocunit/">OCUnit</a>, which comes bundled with Xcode, or <a href="https://code.google.com/p/google-toolbox-for-mac/">GTMSenTestcase</a> are both good choices. <br /><br /><b>Hermetic UI Tests </b><br /><a href="https://github.com/kif-framework/KIF">KIF</a> has proven to be a powerful solution for writing Objective-C UI tests. It runs in-process which allows tests to be more tightly coupled with the app under test, making the tests inherently more stable. KIF allows iOS developers to write tests using the same language as their application. <br /><br />Following the same paradigm as Android UI tests, you want Objective-C tests to be hermetic. A good approach is to mock the server with pre-canned responses. Since KIF tests run in-process, responses can be built programmatically, making tests easier to maintain and more stable. <br /><br /><b>Monkey Tests </b><br />iOS has no equivalent native tool for writing monkey tests as Android does, however this type of test still adds value in iOS (e.g. we found 16 crashes in one of our recent Google+ releases). The Google+ team developed their own custom monkey testing framework, but there are also many third-party options available. <br /><br /><b><span>Backend Testing </span></b><br /><br />A mobile testing strategy is not complete without testing the integration between server backends and mobile clients. This is especially true when the release cycles of the mobile clients and backends are very different. A replay test strategy can be very effective at preventing backends from breaking mobile clients. The theory behind this strategy is to simulate mobile clients by having a set of golden request and response files that are known to be correct. The replay test suite should then send golden requests to the backend server and assert that the response returned by the server matches the expected golden response. Since client/server responses are often not completely deterministic, you will need to utilize a diffing tool that can ignore expected differences. <br /><br />To make this strategy successful you need a way to seed a repeatable data set on the backend and make all dependencies that are not relevant to your backend hermetic. Using in-memory servers with fake data or an RPC replay to external dependencies are good ways of achieving repeatable data sets and hermetic environments. Google+ mobile backend uses <a href="https://code.google.com/p/google-guice/">Guice</a> for dependency injection, which allows us to easily swap out dependencies with fake implementations during testing and seed data fixtures. <br /><br /><div><b>Diagram: Normal flow vs Replay Tests flow </b></div><div><a href="http://3.bp.blogspot.com/-3w15bC7RSj8/UiDwRP-Ob_I/AAAAAAAAADY/9gmTy3HDMZg/s1600/diagram2.png"><img border="0" height="230" src="http://3.bp.blogspot.com/-3w15bC7RSj8/UiDwRP-Ob_I/AAAAAAAAADY/9gmTy3HDMZg/s640/diagram2.png" width="640"></a></div><br /><br /><b><span>Conclusion </span></b><br /><br />Mobile app testing can be very challenging, but building a comprehensive test strategy that understands the nature of different platforms and tools is the key to success. Providing a reliable and hermetic test environment is as important as the tests you write. <br /><br />Finally, make sure you prioritize your automation efforts according to your team needs. This is how we prioritize on the Google+ team: <br /><ol><li>Unit tests: These should be your first priority in either Android or iOS. They run fast and are less flaky than any other type of tests. </li><li>Backend tests: Make sure your backend doesn&#8217;t break your mobile clients. Breakages are very likely to happen when the release cycle of mobile clients and backends are different. </li><li>UI tests: These are slower by nature and flaky. They also take more time to write and maintain. Make sure you provide coverage for at least the critical paths of your app. </li><li>Monkey tests: This is the final step to complete your mobile automation strategy. </li></ol><br /><br />Happy mobile testing from the Google+ team.]]></description>
				<content:encoded><![CDATA[<i>by Eduardo Bravo Ortiz </i><br /><br />“Mobile first” is the motto these days for many companies. However, being able to test a mobile app in a meaningful way is very challenging. On the Google+ team we have had our share of trial and error that has led us to successful strategies for testing mobile applications on both iOS and Android. <br /><br /><span style="color: blue;"><b>General </b></span><br /><br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Understand the platform. Testing on Android is not the same as testing on iOS. The testing tools and frameworks available for each platform are significantly different. (e.g., Android uses Java while iOS uses Objective-C, UI layouts are built differently on each platform, UI testing frameworks also work very differently in both platforms.) </li><li>Stabilize your test suite and test environments. Flaky tests are worse than having no tests, because a flaky test pollutes your build health and decreases the credibility of your suite. </li><li>Break down testing into manageable pieces. There are too many complex pieces when testing on mobile (e.g., emulator/device state, actions triggered by the OS).  </li><li>Provide a <a href="http://googletesting.blogspot.com/2012/10/hermetic-servers.html">hermetic test</a> environment for your tests. Mobile UI tests are flaky by nature; don’t add more flakiness to them by having external dependencies. </li><li>Unit tests are the backbone of your mobile test strategy. Try to separate the app code logic from the UI as much as possible. This separation will make unit tests more granular and faster. </li></ul><br /><br /><b><span style="color: blue;">Android Testing </span></b><br /><br /><b>Unit Tests </b><br />Separating UI code from code logic is especially hard in Android. For example, an Activity is expected to act as a controller and view at the same time; make sure you keep this in mind when writing unit tests. Another useful recommendation is to decouple unit tests from the Android emulator, this will remove the need to build an APK and install it and your tests will run much faster. <a href="http://pivotal.github.io/robolectric/">Robolectric</a> is a perfect tool for this; it stubs the implementation of the Android platform while running tests. <br /><br /><b>Hermetic UI Tests </b><br />A hermetic UI test typically runs as a test without network calls or external dependencies. Once the tests can run in a <a href="http://googletesting.blogspot.com/2012/10/hermetic-servers.html">hermetic environment</a>, a white box testing framework like <a href="http://www.youtube.com/watch?v=T7ugmCuNxDU">Espresso</a> can simulate user actions on the UI and is tightly coupled to the app code. Espresso will also synchronize your tests actions with events on the UI thread, reducing flakiness. More information on Espresso is coming in a future Google Testing Blog article. <br /><br /><div style="text-align: center;"><b>Diagram: Non-Hermetic Flow vs. Hermetic Flow </b></div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/--yeG5Bgqzas/UiDv4W5iyWI/AAAAAAAAADQ/hwPYIYmaz9M/s1600/diagram1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="199" src="http://1.bp.blogspot.com/--yeG5Bgqzas/UiDv4W5iyWI/AAAAAAAAADQ/hwPYIYmaz9M/s640/diagram1.png" width="640" /></a></div><br /><br /><b>Monkey Tests </b><br />Monkey tests look for crashes and <a href="http://developer.android.com/training/articles/perf-anr.html">ANRs</a> by stressing your Android application. They exercise <a href="http://en.wikipedia.org/wiki/Pseudorandom_number_generator">pseudo-random</a> events like clicks or gestures on the app under test. Monkey test results are reproducible to a certain extent; timing and latency are not completely under your control and can cause a test failure. Re-running the same monkey test against the same configuration will often reproduce these failures, though. If you run them daily against different SDKs, they are very effective at catching bugs earlier in the development cycle of a new release. <br /><br /><b><span style="color: blue;">iOS Testing </span></b><br /><br /><b>Unit Tests </b><br />Unit test frameworks like <a href="http://www.sente.ch/software/ocunit/">OCUnit</a>, which comes bundled with Xcode, or <a href="https://code.google.com/p/google-toolbox-for-mac/">GTMSenTestcase</a> are both good choices. <br /><br /><b>Hermetic UI Tests </b><br /><a href="https://github.com/kif-framework/KIF">KIF</a> has proven to be a powerful solution for writing Objective-C UI tests. It runs in-process which allows tests to be more tightly coupled with the app under test, making the tests inherently more stable. KIF allows iOS developers to write tests using the same language as their application. <br /><br />Following the same paradigm as Android UI tests, you want Objective-C tests to be hermetic. A good approach is to mock the server with pre-canned responses. Since KIF tests run in-process, responses can be built programmatically, making tests easier to maintain and more stable. <br /><br /><b>Monkey Tests </b><br />iOS has no equivalent native tool for writing monkey tests as Android does, however this type of test still adds value in iOS (e.g. we found 16 crashes in one of our recent Google+ releases). The Google+ team developed their own custom monkey testing framework, but there are also many third-party options available. <br /><br /><b><span style="color: blue;">Backend Testing </span></b><br /><br />A mobile testing strategy is not complete without testing the integration between server backends and mobile clients. This is especially true when the release cycles of the mobile clients and backends are very different. A replay test strategy can be very effective at preventing backends from breaking mobile clients. The theory behind this strategy is to simulate mobile clients by having a set of golden request and response files that are known to be correct. The replay test suite should then send golden requests to the backend server and assert that the response returned by the server matches the expected golden response. Since client/server responses are often not completely deterministic, you will need to utilize a diffing tool that can ignore expected differences. <br /><br />To make this strategy successful you need a way to seed a repeatable data set on the backend and make all dependencies that are not relevant to your backend hermetic. Using in-memory servers with fake data or an RPC replay to external dependencies are good ways of achieving repeatable data sets and hermetic environments. Google+ mobile backend uses <a href="https://code.google.com/p/google-guice/">Guice</a> for dependency injection, which allows us to easily swap out dependencies with fake implementations during testing and seed data fixtures. <br /><br /><div style="text-align: center;"><b>Diagram: Normal flow vs Replay Tests flow </b></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-3w15bC7RSj8/UiDwRP-Ob_I/AAAAAAAAADY/9gmTy3HDMZg/s1600/diagram2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="230" src="http://3.bp.blogspot.com/-3w15bC7RSj8/UiDwRP-Ob_I/AAAAAAAAADY/9gmTy3HDMZg/s640/diagram2.png" width="640" /></a></div><br /><br /><b><span style="color: blue;">Conclusion </span></b><br /><br />Mobile app testing can be very challenging, but building a comprehensive test strategy that understands the nature of different platforms and tools is the key to success. Providing a reliable and hermetic test environment is as important as the tests you write. <br /><br />Finally, make sure you prioritize your automation efforts according to your team needs. This is how we prioritize on the Google+ team: <br /><ol style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Unit tests: These should be your first priority in either Android or iOS. They run fast and are less flaky than any other type of tests. </li><li>Backend tests: Make sure your backend doesn’t break your mobile clients. Breakages are very likely to happen when the release cycle of mobile clients and backends are different. </li><li>UI tests: These are slower by nature and flaky. They also take more time to write and maintain. Make sure you provide coverage for at least the critical paths of your app. </li><li>Monkey tests: This is the final step to complete your mobile automation strategy. </li></ol><br /><br />Happy mobile testing from the Google+ team.]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/how-the-google-team-tests-mobile-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Test Behavior, Not Implementation</title>
		<link>https://googledata.org/uncategorized/testing-on-the-toilet-test-behavior-not-implementation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-test-behavior-not-implementation</link>
		<comments>https://googledata.org/uncategorized/testing-on-the-toilet-test-behavior-not-implementation/#comments</comments>
		<pubDate>Mon, 05 Aug 2013 19:04:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
		
		<guid isPermaLink="false">https://googledata.org/?guid=fd3304cf1403343d2779f042dd00d30e</guid>
		<description><![CDATA[By Andrew Trenk This article was adapted from a Google Testing on the Toilet (TotT) episode. You can download a printer-friendly version of this TotT episode and post it in your office. Your trusty Calculator class is one of your most popular open sour...]]></description>
				<content:encoded><![CDATA[By Andrew Trenk <br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/file/d/0B_EQS8-2f7m5RXJvRzFIcUtMVjg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br />Your trusty Calculator class is one of your most popular open source projects, with many happy users: <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">public</span> <span style="color: #0433ff;">class</span> Calculator {<br />  <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">int</span> <b>add</b>(<span style="color: #0433ff;">int</span> <b>a</b>, <span style="color: #0433ff;">int</span> <b>b</b>) {<br />    <span style="color: #0433ff;">return</span> <b>a</b> + <b>b</b>;<br />  }<br />}</pre><br /><b>You also have tests</b> to help ensure that it works properly: <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> <b>testAdd</b>() {<br />  assertEquals(<b>3</b>, calculator.<b>add</b>(<b>2</b>, <b>1</b>));<br />  assertEquals(<b>2</b>, calculator.<b>add</b>(<b>2</b>, <b>0</b>));<br />  assertEquals(<b>1</b>, calculator.<b>add</b>(<b>2</b>, <b>-1</b>));<br />}</pre><br />However, a fancy new library promises several orders of magnitude speedup in your code if you use it in place of the addition operator. You excitedly <b>change your code</b> to use this library: <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">public</span> <span style="color: #0433ff;">class</span> Calculator {<br />  <span style="color: #0433ff;">private</span> AdderFactory <b>adderFactory</b>;<br />  <span style="color: #0433ff;">public</span> Calculator(AdderFactor <b>adderFactory</b>) { <span style="color: #0433ff;">this</span>.<b>adderFactory</b> = <b>adderFactory</b>; }<br />  <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">int</span> <b>add</b>(<span style="color: #0433ff;">int</span> <b>a</b>, <span style="color: #0433ff;">int</span> <b>b</b>) {<br />    Adder <b>adder</b> = <b>adderFactory</b>.createAdder();<br />    ReturnValue <b>returnValue</b> = <b>adder</b>.compute(<span style="color: #0433ff;">new</span> Number(<b>a</b>), <span style="color: #0433ff;">new</span> Number(<b>b</b>));<br />    <span style="color: #0433ff;">return</span> <b>returnValue</b>.convertToInteger();<br />  }<br />}</pre><br />That was easy, but what do you do about the tests for this code? <b>None of the existing tests should need to change</b> since you only changed the code's implementation, but its user-facing behavior didn't change. In most cases, <b>tests should focus on testing your code's public API, and your code's implementation details shouldn't need to be exposed to tests</b>. <br /><br /><b>Tests that are independent of implementation details are easier to maintain</b> since they don't need to be changed each time you make a change to the implementation. <b>They're also easier to understand</b> since they basically act as code samples that show all the different ways your class's methods can be used, so even someone who's not familiar with the implementation should usually be able to read through the tests to understand how to use the class. <br /><br /><b>There are many cases where you do want to test implementation details</b> (e.g. you want to ensure that your implementation reads from a cache instead of from a datastore), <b>but this should be less common</b> since in most cases your tests should be independent of your implementation. <br /><br />Note that <b>test setup may need to change if the implementation changes</b> (e.g. if you change your class to take a new dependency in its constructor, the test needs to pass in this dependency when it creates the class), but the actual test itself typically shouldn't need to change if the code's user-facing behavior doesn't change. ]]></content:encoded>
			<wfw:commentRss>https://googledata.org/uncategorized/testing-on-the-toilet-test-behavior-not-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Know Your Test Doubles</title>
		<link>https://googledata.org/google-testing/testing-on-the-toilet-know-your-test-doubles/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-know-your-test-doubles</link>
		<comments>https://googledata.org/google-testing/testing-on-the-toilet-know-your-test-doubles/#comments</comments>
		<pubDate>Thu, 18 Jul 2013 17:45:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=f8e8c80bdcc8721d1ed82d91ddf9ae69</guid>
		<description><![CDATA[By Andrew Trenk <br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/file/d/0B_EQS8-2f7m5Y1lTcDRnekk3Rjg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><b>A test double is an object that can stand in for a real object in a test</b>, similar to how a stunt double stands in for an actor in a movie. These are sometimes all commonly referred to as &#8220;mocks&#8221;, but it's important to distinguish between the different types of test doubles since they all have different uses. <b>The most common types of test doubles are stubs, mocks, and fakes. </b><br /><br />A <b>stub</b> has no logic, and only returns what you tell it to return. <b>Stubs can be used when you need an object to return specific values in order to get your code under test into a certain state.</b> While it's usually easy to write stubs by hand, using a mocking framework is often a convenient way to reduce boilerplate. <br /><br /><pre><span>// Pass in a stub that was created by a mocking framework.</span><br />AccessManager <b>accessManager</b> = <span>new</span> AccessManager(<b>stubAuthenticationService</b>);<br /><span>// The user shouldn't have access when the authentication service returns false.</span><br />when(<b>stubAuthenticationService</b>.isAuthenticated(USER_ID)).thenReturn(<span>false</span>);<br />assertFalse(<b>accessManager</b>.userHasAccess(USER_ID));<br /><span>// The user should have access when the authentication service returns true. </span><br />when(<b>stubAuthenticationService</b>.isAuthenticated(USER_ID)).thenReturn(<span>true</span>);<br />assertTrue(<b>accessManager</b>.userHasAccess(USER_ID));<br /></pre><br />A <b>mock</b> has expectations about the way it should be called, and a test should fail if it&#8217;s not called that way. <b>Mocks are used to test interactions between objects</b>, and are useful in cases where there are no other visible state  changes or return results that you can verify (e.g. if your code reads from disk and you want to ensure that it doesn't do more than one disk read, you can use a mock to verify that the method that does the read is only called once). <br /><br /><pre><span>// Pass in a mock that was created by a mocking framework.</span><br />AccessManager <b>accessManager</b> = <span>new</span> AccessManager(<b>mockAuthenticationService</b>);<br /><b>accessManager</b>.userHasAccess(USER_ID);<br /><span>// The test should fail if accessManager.userHasAccess(USER_ID) didn't call</span><br /><span>// mockAuthenticationService.isAuthenticated(USER_ID) or if it called it more than once.</span><br />verify(<b>mockAuthenticationService</b>).isAuthenticated(USER_ID);</pre><br />A <b>fake</b> doesn&#8217;t use a mocking framework: it&#8217;s a lightweight implementation of an API that behaves like the real implementation, but isn't suitable for production (e.g. an in-memory database). <b>Fakes can be used when you can't use a real implementation in your test</b> (e.g. if the real implementation is too slow or it talks over the network). You shouldn't need to write your own fakes often since fakes should usually be created and maintained by the person or team that owns the real implementation. <br /><br /><pre><span>// Creating the fake is fast and easy.</span><br />AuthenticationService <b>fakeAuthenticationService</b> = <span>new</span> FakeAuthenticationService();<br />AccessManager <b>accessManager</b> = <span>new</span> AccessManager(<b>fakeAuthenticationService</b>);<br /><span>// The user shouldn't have access since the authentication service doesn't</span><br /><span>// know about the user.</span><br />assertFalse(<b>accessManager</b>.userHasAccess(USER_ID));<br /><span>// The user should have access after it's added to the authentication service.</span><br /><b>fakeAuthenticationService</b>.addAuthenticatedUser(USER_ID);<br />assertTrue(<b>accessManager</b>.userHasAccess(USER_ID));</pre><br /><i>The term &#8220;test double&#8221; was coined by Gerard Meszaros in the book xUnit Test Patterns. You can find more information about test doubles in the book, or on the book&#8217;s <a href="http://xunitpatterns.com/Test%20Double%20Patterns.html">website</a>. You can also find a discussion about the different types of test doubles in this <a href="http://martinfowler.com/articles/mocksArentStubs.html">article</a> by Martin Fowler. </i><br /><br />]]></description>
				<content:encoded><![CDATA[By Andrew Trenk <br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/file/d/0B_EQS8-2f7m5Y1lTcDRnekk3Rjg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br /><b>A test double is an object that can stand in for a real object in a test</b>, similar to how a stunt double stands in for an actor in a movie. These are sometimes all commonly referred to as “mocks”, but it's important to distinguish between the different types of test doubles since they all have different uses. <b>The most common types of test doubles are stubs, mocks, and fakes. </b><br /><br />A <b>stub</b> has no logic, and only returns what you tell it to return. <b>Stubs can be used when you need an object to return specific values in order to get your code under test into a certain state.</b> While it's usually easy to write stubs by hand, using a mocking framework is often a convenient way to reduce boilerplate. <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #4f8f00;">// Pass in a stub that was created by a mocking framework.</span><br />AccessManager <b>accessManager</b> = <span style="color: #0433ff;">new</span> AccessManager(<b>stubAuthenticationService</b>);<br /><span style="color: #4f8f00;">// The user shouldn't have access when the authentication service returns false.</span><br />when(<b>stubAuthenticationService</b>.isAuthenticated(USER_ID)).thenReturn(<span style="color: #0433ff;">false</span>);<br />assertFalse(<b>accessManager</b>.userHasAccess(USER_ID));<br /><span style="color: #4f8f00;">// The user should have access when the authentication service returns true. </span><br />when(<b>stubAuthenticationService</b>.isAuthenticated(USER_ID)).thenReturn(<span style="color: #0433ff;">true</span>);<br />assertTrue(<b>accessManager</b>.userHasAccess(USER_ID));<br /></pre><br />A <b>mock</b> has expectations about the way it should be called, and a test should fail if it’s not called that way. <b>Mocks are used to test interactions between objects</b>, and are useful in cases where there are no other visible state  changes or return results that you can verify (e.g. if your code reads from disk and you want to ensure that it doesn't do more than one disk read, you can use a mock to verify that the method that does the read is only called once). <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #4f8f00;">// Pass in a mock that was created by a mocking framework.</span><br />AccessManager <b>accessManager</b> = <span style="color: #0433ff;">new</span> AccessManager(<b>mockAuthenticationService</b>);<br /><b>accessManager</b>.userHasAccess(USER_ID);<br /><span style="color: #4f8f00;">// The test should fail if accessManager.userHasAccess(USER_ID) didn't call</span><br /><span style="color: #4f8f00;">// mockAuthenticationService.isAuthenticated(USER_ID) or if it called it more than once.</span><br />verify(<b>mockAuthenticationService</b>).isAuthenticated(USER_ID);</pre><br />A <b>fake</b> doesn’t use a mocking framework: it’s a lightweight implementation of an API that behaves like the real implementation, but isn't suitable for production (e.g. an in-memory database). <b>Fakes can be used when you can't use a real implementation in your test</b> (e.g. if the real implementation is too slow or it talks over the network). You shouldn't need to write your own fakes often since fakes should usually be created and maintained by the person or team that owns the real implementation. <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #4f8f00;">// Creating the fake is fast and easy.</span><br />AuthenticationService <b>fakeAuthenticationService</b> = <span style="color: #0433ff;">new</span> FakeAuthenticationService();<br />AccessManager <b>accessManager</b> = <span style="color: #0433ff;">new</span> AccessManager(<b>fakeAuthenticationService</b>);<br /><span style="color: #4f8f00;">// The user shouldn't have access since the authentication service doesn't</span><br /><span style="color: #4f8f00;">// know about the user.</span><br />assertFalse(<b>accessManager</b>.userHasAccess(USER_ID));<br /><span style="color: #4f8f00;">// The user should have access after it's added to the authentication service.</span><br /><b>fakeAuthenticationService</b>.addAuthenticatedUser(USER_ID);<br />assertTrue(<b>accessManager</b>.userHasAccess(USER_ID));</pre><br /><i>The term “test double” was coined by Gerard Meszaros in the book xUnit Test Patterns. You can find more information about test doubles in the book, or on the book’s <a href="http://xunitpatterns.com/Test%20Double%20Patterns.html">website</a>. You can also find a discussion about the different types of test doubles in this <a href="http://martinfowler.com/articles/mocksArentStubs.html">article</a> by Martin Fowler. </i><br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/testing-on-the-toilet-know-your-test-doubles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Fake Your Way to Better Tests</title>
		<link>https://googledata.org/uncategorized/testing-on-the-toilet-fake-your-way-to-better-tests/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-fake-your-way-to-better-tests</link>
		<comments>https://googledata.org/uncategorized/testing-on-the-toilet-fake-your-way-to-better-tests/#comments</comments>
		<pubDate>Fri, 28 Jun 2013 19:17:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
		
		<guid isPermaLink="false">https://googledata.org/?guid=242c91b9d9be5f82072ef3dccab54cd0</guid>
		<description><![CDATA[<i>By Jonathan Rockway and Andrew Trenk </i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/file/d/0B_EQS8-2f7m5MFdIN1NmOFFHZTg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br />After many years of blogging, you decide to try out your blog platform's API. You start playing around with it, but then you realize: how can you tell that your code works without having your test talk to a remote blog server? <br /><br /><pre><span>public</span> <span>void</span> deletePostsWithTag(Tag <b>tag</b>) {<br /><span>for</span> (Post <b>post</b> : <b>blogService</b>.getAllPosts()) {<br /><span>if</span> (<b>post</b>.getTags().contains(<b>tag</b>)) { <b>blogService</b>.deletePost(<b>post</b>.getId()); }<br />  }<br />}<br /></pre><br />Fakes to the rescue! <b>A fake is a lightweight implementation of an API that behaves like the real implementation, but isn't suitable for production</b>. In the case of the blog service, all you care about is the ability to retrieve and delete posts. While a real blog service would need a database and support multiple frontend servers, you don&#8217;t need any of that to test your code, all you need is any implementation of the blog service API. You can achieve this with a simple in-memory implementation: <br /><br /><pre><span>public</span> <span>class</span> <b>FakeBlogService</b> <span>implements</span> <b>BlogService</b> {  <br /><span>private</span> <span>final</span> Set&#60;Post&#62; <b>posts</b> = <span>new</span> HashSet&#60;Post&#62;(); <span>// Store posts in memory</span><br /><span>public</span> <span>void</span> addPost(Post <b>post</b>) { <b>posts</b>.add(<b>post</b>); }<br /><span>public</span> <span>void</span> deletePost(<span>int</span> <b>id</b>) {<br /><span>for</span> (Post <b>post</b> : <b>posts</b>) {<br /><span>if</span> (<b>post</b>.getId() == <b>id</b>) { <b>posts</b>.remove(<b>post</b>); <span>return</span>; }<br />    }<br /><span>throw</span> <span>new</span> PostNotFoundException(<span>"No post with ID "</span> + <b>id</b>);<br />  }<br /><span>public</span> Set&#60;Post&#62; getAllPosts() { <span>return</span> <b>posts</b>; }<br />}<br /></pre><br />Now your tests can swap out the real blog service with the fake and the code under test won't even know the difference. <br /><br /><b>Fakes are useful for when you can't use the real implementation in a test</b>, such as if the real implementation is too slow (e.g. it takes several minutes to start up) or if it's non-deterministic (e.g. it talks to an external machine that may not be available when your test runs). <br /><br />You shouldn't need to write your own fakes often since <b>each fake should be created and maintained by the person or team that owns the real implementation</b>. If you&#8217;re using an API that doesn't provide a fake, it&#8217;s often easy to create one yourself: write a wrapper around the part of the code that you can't use in your tests, and create a fake for that wrapper. <b>Remember to create the fake at the lowest level possible</b> (e.g. if you can't use a database in your tests, fake out the database instead of faking out all of your classes that talk to the database), that way you'll have fewer fakes to maintain, and your tests will be executing more real code for important parts of your system. <br /><br /><b>Fakes should have their own tests</b> to ensure that they behave like the real implementation (e.g. if the real implementation throws an exception when given certain input, the fake implementation should also throw an exception when given the same input). One way to do this is to write tests against the API's public interface, and run those tests against both the real and fake implementations. <br /><br />If you still don't fully trust that your code will work in production if all your tests use a fake, you can write a small number of integration tests to ensure that your code will work with the real implementation.]]></description>
				<content:encoded><![CDATA[<i>By Jonathan Rockway and Andrew Trenk </i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="https://docs.google.com/file/d/0B_EQS8-2f7m5MFdIN1NmOFFHZTg/edit?usp=sharing">printer-friendly version</a> of this TotT episode and post it in your office. </i><br /><br />After many years of blogging, you decide to try out your blog platform's API. You start playing around with it, but then you realize: how can you tell that your code works without having your test talk to a remote blog server? <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> deletePostsWithTag(Tag <b>tag</b>) {<br />  <span style="color: #0433ff;">for</span> (Post <b>post</b> : <b>blogService</b>.getAllPosts()) {<br />    <span style="color: #0433ff;">if</span> (<b>post</b>.getTags().contains(<b>tag</b>)) { <b>blogService</b>.deletePost(<b>post</b>.getId()); }<br />  }<br />}<br /></pre><br />Fakes to the rescue! <b>A fake is a lightweight implementation of an API that behaves like the real implementation, but isn't suitable for production</b>. In the case of the blog service, all you care about is the ability to retrieve and delete posts. While a real blog service would need a database and support multiple frontend servers, you don’t need any of that to test your code, all you need is any implementation of the blog service API. You can achieve this with a simple in-memory implementation: <br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;"><span style="color: #0433ff;">public</span> <span style="color: #0433ff;">class</span> <b>FakeBlogService</b> <span style="color: #0433ff;">implements</span> <b>BlogService</b> {  <br />  <span style="color: #0433ff;">private</span> <span style="color: #0433ff;">final</span> Set&lt;Post&gt; <b>posts</b> = <span style="color: #0433ff;">new</span> HashSet&lt;Post&gt;(); <span style="color: #4f8f00;">// Store posts in memory</span><br />  <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> addPost(Post <b>post</b>) { <b>posts</b>.add(<b>post</b>); }<br />  <span style="color: #0433ff;">public</span> <span style="color: #0433ff;">void</span> deletePost(<span style="color: #0433ff;">int</span> <b>id</b>) {<br />    <span style="color: #0433ff;">for</span> (Post <b>post</b> : <b>posts</b>) {<br />      <span style="color: #0433ff;">if</span> (<b>post</b>.getId() == <b>id</b>) { <b>posts</b>.remove(<b>post</b>); <span style="color: #0433ff;">return</span>; }<br />    }<br />    <span style="color: #0433ff;">throw</span> <span style="color: #0433ff;">new</span> PostNotFoundException(<span style="color: #ff2600;">"No post with ID "</span> + <b>id</b>);<br />  }<br />  <span style="color: #0433ff;">public</span> Set&lt;Post&gt; getAllPosts() { <span style="color: #0433ff;">return</span> <b>posts</b>; }<br />}<br /></pre><br />Now your tests can swap out the real blog service with the fake and the code under test won't even know the difference. <br /><br /><b>Fakes are useful for when you can't use the real implementation in a test</b>, such as if the real implementation is too slow (e.g. it takes several minutes to start up) or if it's non-deterministic (e.g. it talks to an external machine that may not be available when your test runs). <br /><br />You shouldn't need to write your own fakes often since <b>each fake should be created and maintained by the person or team that owns the real implementation</b>. If you’re using an API that doesn't provide a fake, it’s often easy to create one yourself: write a wrapper around the part of the code that you can't use in your tests, and create a fake for that wrapper. <b>Remember to create the fake at the lowest level possible</b> (e.g. if you can't use a database in your tests, fake out the database instead of faking out all of your classes that talk to the database), that way you'll have fewer fakes to maintain, and your tests will be executing more real code for important parts of your system. <br /><br /><b>Fakes should have their own tests</b> to ensure that they behave like the real implementation (e.g. if the real implementation throws an exception when given certain input, the fake implementation should also throw an exception when given the same input). One way to do this is to write tests against the API's public interface, and run those tests against both the real and fake implementations. <br /><br />If you still don't fully trust that your code will work in production if all your tests use a fake, you can write a small number of integration tests to ensure that your code will work with the real implementation.  ]]></content:encoded>
			<wfw:commentRss>https://googledata.org/uncategorized/testing-on-the-toilet-fake-your-way-to-better-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Optimal Logging</title>
		<link>https://googledata.org/google-testing/optimal-logging/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=optimal-logging</link>
		<comments>https://googledata.org/google-testing/optimal-logging/#comments</comments>
		<pubDate>Fri, 14 Jun 2013 14:58:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=99045ac8b2a79a62d8db2088c822d3fc</guid>
		<description><![CDATA[<i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><br />How long does it take to find the root cause of a failure in your system? Five minutes? Five days? If you answered close to five minutes, it&#8217;s very likely that your production system and tests have great logging. All too often, seemingly unessential features like logging, exception handling, and (dare I say it) testing are an implementation afterthought. Like exception handling and testing, you really need to have a strategy for logging in both your systems and your tests. Never underestimate the power of logging. With optimal logging, you can even eliminate the necessity for debuggers. Below are some guidelines that have been useful to me over the years.<br /><br /><br /><b>Channeling Goldilocks</b><br /><br />Never log too much. Massive, disk-quota burning logs are a clear indicator that little thought was put in to logging. If you log too much, you&#8217;ll need to devise complex approaches to minimize disk access, maintain log history, archive large quantities of data, and query these large sets of data. More importantly, you&#8217;ll make it very difficult to find valuable information in all the chatter.<br /><br />The only thing worse than logging too much is logging too little. There are normally two main goals of logging: help with bug investigation and event confirmation. If your log can&#8217;t explain the cause of a bug or whether a certain transaction took place, you are logging too little.<br /><br />Good things to log: <br /><ul><li>Important startup configuration</li><li>Errors</li><li>Warnings</li><li>Changes to persistent data</li><li>Requests and responses between major system components</li><li>Significant state changes</li><li>User interactions</li><li>Calls with a known risk of failure</li><li>Waits on conditions that could take measurable time to satisfy</li><li>Periodic progress during long-running tasks</li><li>Significant branch points of logic and conditions that led to the branch</li><li>Summaries of processing steps or events from high level functions - Avoid logging every step of a complex process in low-level functions.</li></ul><br />Bad things to log: <br /><ul><li>Function entry - Don&#8217;t log a function entry unless it is significant or logged at the debug level.</li><li>Data within a loop - Avoid logging from many iterations of a loop. It is OK to log from iterations of small loops or to log periodically from large loops.</li><li>Content of large messages or files - Truncate or summarize the data in some way that will be useful to debugging.</li><li>Benign errors - Errors that are not really errors can confuse the log reader. This sometimes happens when exception handling is part of successful execution flow.</li><li>Repetitive errors - Do not repetitively log the same or similar error. This can quickly fill a log and hide the actual cause. Frequency of error types is best handled by monitoring. Logs only need to capture detail for some of those errors.</li></ul><br /><br /><b>There is More Than One Level</b><br /><br />Don't log everything at the same log level. Most logging libraries offer several log levels, and you can enable certain levels at system startup. This provides a convenient control for log verbosity.<br /><br />The classic levels are: <br /><ul><li>Debug - verbose and only useful while developing and/or debugging.</li><li>Info - the most popular level.</li><li>Warning - strange or unexpected states that are acceptable.</li><li>Error - something went wrong, but the process can recover.</li><li>Critical - the process cannot recover, and it will shutdown or restart.</li></ul><br />Practically speaking, only two log configurations are needed: <br /><ul><li>Production - Every level is enabled except debug. If something goes wrong in production, the logs should reveal the cause.</li><li>Development &#38; Debug - While developing new code or trying to reproduce a production issue, enable all levels.</li></ul><br /><br /><b>Test Logs Are Important Too</b><br /><br />Log quality is equally important in test and production code. When a test fails, the log should clearly show whether the failure was a problem with the test or production system. If it doesn't, then test logging is broken.<br /><br />Test logs should always contain: <br /><ul><li>Test execution environment</li><li>Initial state</li><li>Setup steps</li><li>Test case steps</li><li>Interactions with the system</li><li>Expected results</li><li>Actual results</li><li>Teardown steps</li></ul><br /><br /><b>Conditional Verbosity With Temporary Log Queues</b><br /><br />When errors occur, the log should contain a lot of detail. Unfortunately, detail that led to an error is often unavailable once the error is encountered. Also, if you&#8217;ve followed advice about not logging too much, your log records prior to the error record may not provide adequate detail. A good way to solve this problem is to create temporary, in-memory log queues. Throughout processing of a transaction, append verbose details about each step to the queue. If the transaction completes successfully, discard the queue and log a summary. If an error is encountered, log the content of the entire queue and the error. This technique is especially useful for test logging of system interactions.<br /><br /><br /><b>Failures and Flakiness Are Opportunities</b><br /><br />When production problems occur, you&#8217;ll obviously be focused on finding and correcting the problem, but you should also think about the logs. If you have a hard time determining the cause of an error, it's a great opportunity to improve your logging. Before fixing the problem, fix your logging so that the logs clearly show the cause. If this problem ever happens again, it&#8217;ll be much easier to identify.<br /><br />If you cannot reproduce the problem, or you have a flaky test, enhance the logs so that the problem can be tracked down when it happens again.<br /><br />Using failures to improve logging should be used throughout the development process. While writing new code, try to refrain from using debuggers and only use the logs. Do the logs describe what is going on? If not, the logging is insufficient.<br /><br /><br /><b>Might As Well Log Performance Data</b><br /><br />Logged timing data can help debug performance issues. For example, it can be very difficult to determine the cause of a timeout in a large system, unless you can trace the time spent on every significant processing step. This can be easily accomplished by logging the start and finish times of calls that can take measurable time: <br /><ul><li>Significant system calls</li><li>Network requests</li><li>CPU intensive operations</li><li>Connected device interactions</li><li>Transactions</li></ul><br /><br /><b>Following the Trail Through Many Threads and Processes</b><br /><br />You should create unique identifiers for transactions that involve processing across many threads and/or processes. The initiator of the transaction should create the ID, and it should be passed to every component that performs work for the transaction. This ID should be logged by each component when logging information about the transaction. This makes it much easier to trace a specific transaction when many transactions are being processed concurrently.<br /><br /><br /><b>Monitoring and Logging Complement Each Other</b><br /><br />A production service should have both logging and monitoring. Monitoring provides a real-time statistical summary of the system state. It can alert you if a percentage of certain request types are failing, it is experiencing unusual traffic patterns, performance is degrading, or other anomalies occur. In some cases, this information alone will clue you to the cause of a problem. However, in most cases, a monitoring alert is simply a trigger for you to start an investigation. Monitoring shows the symptoms of problems. Logs provide details and state on individual transactions, so you can fully understand the cause of problems.<br /><div><br /></div>]]></description>
				<content:encoded><![CDATA[<i>by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a></i><br /><br />How long does it take to find the root cause of a failure in your system? Five minutes? Five days? If you answered close to five minutes, it’s very likely that your production system and tests have great logging. All too often, seemingly unessential features like logging, exception handling, and (dare I say it) testing are an implementation afterthought. Like exception handling and testing, you really need to have a strategy for logging in both your systems and your tests. Never underestimate the power of logging. With optimal logging, you can even eliminate the necessity for debuggers. Below are some guidelines that have been useful to me over the years.<br /><br /><br /><b>Channeling Goldilocks</b><br /><br />Never log too much. Massive, disk-quota burning logs are a clear indicator that little thought was put in to logging. If you log too much, you’ll need to devise complex approaches to minimize disk access, maintain log history, archive large quantities of data, and query these large sets of data. More importantly, you’ll make it very difficult to find valuable information in all the chatter.<br /><br />The only thing worse than logging too much is logging too little. There are normally two main goals of logging: help with bug investigation and event confirmation. If your log can’t explain the cause of a bug or whether a certain transaction took place, you are logging too little.<br /><br />Good things to log: <br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Important startup configuration</li><li>Errors</li><li>Warnings</li><li>Changes to persistent data</li><li>Requests and responses between major system components</li><li>Significant state changes</li><li>User interactions</li><li>Calls with a known risk of failure</li><li>Waits on conditions that could take measurable time to satisfy</li><li>Periodic progress during long-running tasks</li><li>Significant branch points of logic and conditions that led to the branch</li><li>Summaries of processing steps or events from high level functions - Avoid logging every step of a complex process in low-level functions.</li></ul><br />Bad things to log: <br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Function entry - Don’t log a function entry unless it is significant or logged at the debug level.</li><li>Data within a loop - Avoid logging from many iterations of a loop. It is OK to log from iterations of small loops or to log periodically from large loops.</li><li>Content of large messages or files - Truncate or summarize the data in some way that will be useful to debugging.</li><li>Benign errors - Errors that are not really errors can confuse the log reader. This sometimes happens when exception handling is part of successful execution flow.</li><li>Repetitive errors - Do not repetitively log the same or similar error. This can quickly fill a log and hide the actual cause. Frequency of error types is best handled by monitoring. Logs only need to capture detail for some of those errors.</li></ul><br /><br /><b>There is More Than One Level</b><br /><br />Don't log everything at the same log level. Most logging libraries offer several log levels, and you can enable certain levels at system startup. This provides a convenient control for log verbosity.<br /><br />The classic levels are: <br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Debug - verbose and only useful while developing and/or debugging.</li><li>Info - the most popular level.</li><li>Warning - strange or unexpected states that are acceptable.</li><li>Error - something went wrong, but the process can recover.</li><li>Critical - the process cannot recover, and it will shutdown or restart.</li></ul><br />Practically speaking, only two log configurations are needed: <br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Production - Every level is enabled except debug. If something goes wrong in production, the logs should reveal the cause.</li><li>Development &amp; Debug - While developing new code or trying to reproduce a production issue, enable all levels.</li></ul><br /><br /><b>Test Logs Are Important Too</b><br /><br />Log quality is equally important in test and production code. When a test fails, the log should clearly show whether the failure was a problem with the test or production system. If it doesn't, then test logging is broken.<br /><br />Test logs should always contain: <br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Test execution environment</li><li>Initial state</li><li>Setup steps</li><li>Test case steps</li><li>Interactions with the system</li><li>Expected results</li><li>Actual results</li><li>Teardown steps</li></ul><br /><br /><b>Conditional Verbosity With Temporary Log Queues</b><br /><br />When errors occur, the log should contain a lot of detail. Unfortunately, detail that led to an error is often unavailable once the error is encountered. Also, if you’ve followed advice about not logging too much, your log records prior to the error record may not provide adequate detail. A good way to solve this problem is to create temporary, in-memory log queues. Throughout processing of a transaction, append verbose details about each step to the queue. If the transaction completes successfully, discard the queue and log a summary. If an error is encountered, log the content of the entire queue and the error. This technique is especially useful for test logging of system interactions.<br /><br /><br /><b>Failures and Flakiness Are Opportunities</b><br /><br />When production problems occur, you’ll obviously be focused on finding and correcting the problem, but you should also think about the logs. If you have a hard time determining the cause of an error, it's a great opportunity to improve your logging. Before fixing the problem, fix your logging so that the logs clearly show the cause. If this problem ever happens again, it’ll be much easier to identify.<br /><br />If you cannot reproduce the problem, or you have a flaky test, enhance the logs so that the problem can be tracked down when it happens again.<br /><br />Using failures to improve logging should be used throughout the development process. While writing new code, try to refrain from using debuggers and only use the logs. Do the logs describe what is going on? If not, the logging is insufficient.<br /><br /><br /><b>Might As Well Log Performance Data</b><br /><br />Logged timing data can help debug performance issues. For example, it can be very difficult to determine the cause of a timeout in a large system, unless you can trace the time spent on every significant processing step. This can be easily accomplished by logging the start and finish times of calls that can take measurable time: <br /><ul style="line-height: 1em; margin-bottom: 0px; margin-top: 0px; padding-bottom: 0px; padding-top: 0px;"><li>Significant system calls</li><li>Network requests</li><li>CPU intensive operations</li><li>Connected device interactions</li><li>Transactions</li></ul><br /><br /><b>Following the Trail Through Many Threads and Processes</b><br /><br />You should create unique identifiers for transactions that involve processing across many threads and/or processes. The initiator of the transaction should create the ID, and it should be passed to every component that performs work for the transaction. This ID should be logged by each component when logging information about the transaction. This makes it much easier to trace a specific transaction when many transactions are being processed concurrently.<br /><br /><br /><b>Monitoring and Logging Complement Each Other</b><br /><br />A production service should have both logging and monitoring. Monitoring provides a real-time statistical summary of the system state. It can alert you if a percentage of certain request types are failing, it is experiencing unusual traffic patterns, performance is degrading, or other anomalies occur. In some cases, this information alone will clue you to the cause of a problem. However, in most cases, a monitoring alert is simply a trigger for you to start an investigation. Monitoring shows the symptoms of problems. Logs provide details and state on individual transactions, so you can fully understand the cause of problems.<br /><div><br /></div>]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/optimal-logging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Don’t Overuse Mocks</title>
		<link>https://googledata.org/uncategorized/testing-on-the-toilet-dont-overuse-mocks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-dont-overuse-mocks</link>
		<comments>https://googledata.org/uncategorized/testing-on-the-toilet-dont-overuse-mocks/#comments</comments>
		<pubDate>Tue, 28 May 2013 21:34:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
		
		<guid isPermaLink="false">https://googledata.org/?guid=86e7c41e93f66090d4847125f8bd1f45</guid>
		<description><![CDATA[<i>By Andrew Trenk</i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="http://goo.gl/IEfP0">printer-friendly version</a> of this TotT episode and post it in your office.</i><br /><br />When writing tests for your code, <b>it can seem easy to ignore your code's dependencies by mocking them out</b>.<br /><br /><pre>public void <b>testCreditCardIsCharged</b>() {<br /><b>paymentProcessor</b> = new PaymentProcessor(<b>mockCreditCardServer</b>);<br />  when(<b>mockCreditCardServer</b>.isServerAvailable()).thenReturn(true);<br />  when(<b>mockCreditCardServer</b>.beginTransaction()).thenReturn(<b>mockTransactionManager</b>);<br />  when(<b>mockTransactionManager</b>.getTransaction()).thenReturn(<b>transaction</b>);<br />  when(<b>mockCreditCardServer</b>.pay(<b>transaction</b>, <b>creditCard</b>, 500)).thenReturn(<b>mockPayment</b>);<br />  when(<b>mockPayment</b>.isOverMaxBalance()).thenReturn(false);<br /><b>paymentProcessor</b>.processPayment(<b>creditCard</b>, Money.dollars(500));<br />  verify(<b>mockCreditCardServer</b>).pay(<b>transaction</b>, <b>creditCard</b>, 500);<br />}</pre><br />However, <b>not using mocks can sometimes result in tests that are simpler and more useful</b>.<br /><br /><pre>public void <b>testCreditCardIsCharged</b>() {<br /><b>paymentProcessor</b> = new PaymentProcessor(<b>creditCardServer</b>);<br /><b>paymentProcessor</b>.processPayment(<b>creditCard</b>, Money.dollars(500));<br />  assertEquals(500, <b>creditCardServer</b>.getMostRecentCharge(<b>creditCard</b>));<br />}</pre><br /><b>Overusing mocks can cause several problems</b>:<br /><br /><b>- Tests can be harder to understand.</b> Instead of just a straightforward usage of your code (e.g. pass in some values to the method under test and check the return result), you need to include extra code to tell the mocks how to behave. Having this extra code detracts from the actual intent of what you&#8217;re trying to test, and very often this code is hard to understand if you're not familiar with the implementation of the production code.<br /><br /><b>- Tests can be harder to maintain.</b> When you tell a mock how to behave, you're leaking implementation details of your code into your test. When implementation details in your production code change, you'll need to update your tests to reflect these changes. Tests should typically know little about the code's implementation, and should focus on testing the code's public interface.<br /><br /><b>- Tests can provide less assurance that your code is working properly.</b> When you tell a mock how to behave, the only assurance you get with your tests is that your code will work if your mocks behave exactly like your real implementations. This can be very hard to guarantee, and the problem gets worse as your code changes over time, as the behavior of the real implementations is likely to get out of sync with your mocks.<br /><br />Some signs that you're overusing mocks are if you're mocking out more than one or two classes, or if one of your mocks specifies how more than one or two methods should behave. <b>If you're trying to read a test that uses  mocks and find yourself mentally stepping through the code being tested in order to understand the test,  then you're probably overusing mocks</b>.<br /><br /><b>Sometimes you can't use a real dependency in a test</b> (e.g. if it's too slow or talks over the network), <b>but there may better options than using mocks</b>, such as a hermetic local server (e.g. a credit card server that you start up on your machine specifically for the test) or a fake implementation (e.g. an in-memory credit card server).<br /><br /><i>For more information about using hermetic servers, see <a href="http://googletesting.blogspot.com/2012/10/hermetic-servers.html">http://googletesting.blogspot.com/2012/10/hermetic-servers.html</a>. Stay tuned for a future Testing on the Toilet episode about using fake implementations. </i><br /><br />]]></description>
				<content:encoded><![CDATA[<i>By Andrew Trenk</i><br /><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a <a href="http://goo.gl/IEfP0">printer-friendly version</a> of this TotT episode and post it in your office.</i><br /><br />When writing tests for your code, <b>it can seem easy to ignore your code's dependencies by mocking them out</b>.<br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">public void <b>testCreditCardIsCharged</b>() {<br />  <b>paymentProcessor</b> = new PaymentProcessor(<b>mockCreditCardServer</b>);<br />  when(<b>mockCreditCardServer</b>.isServerAvailable()).thenReturn(true);<br />  when(<b>mockCreditCardServer</b>.beginTransaction()).thenReturn(<b>mockTransactionManager</b>);<br />  when(<b>mockTransactionManager</b>.getTransaction()).thenReturn(<b>transaction</b>);<br />  when(<b>mockCreditCardServer</b>.pay(<b>transaction</b>, <b>creditCard</b>, 500)).thenReturn(<b>mockPayment</b>);<br />  when(<b>mockPayment</b>.isOverMaxBalance()).thenReturn(false);<br />  <b>paymentProcessor</b>.processPayment(<b>creditCard</b>, Money.dollars(500));<br />  verify(<b>mockCreditCardServer</b>).pay(<b>transaction</b>, <b>creditCard</b>, 500);<br />}</pre><br />However, <b>not using mocks can sometimes result in tests that are simpler and more useful</b>.<br /><br /><pre style="background: #f9f9f9; border-color: #7b7b7b; border-style: solid; border-width: 1px; color: black; overflow: auto; padding: 10px;">public void <b>testCreditCardIsCharged</b>() {<br />  <b>paymentProcessor</b> = new PaymentProcessor(<b>creditCardServer</b>);<br />  <b>paymentProcessor</b>.processPayment(<b>creditCard</b>, Money.dollars(500));<br />  assertEquals(500, <b>creditCardServer</b>.getMostRecentCharge(<b>creditCard</b>));<br />}</pre><br /><b>Overusing mocks can cause several problems</b>:<br /><br /><b>- Tests can be harder to understand.</b> Instead of just a straightforward usage of your code (e.g. pass in some values to the method under test and check the return result), you need to include extra code to tell the mocks how to behave. Having this extra code detracts from the actual intent of what you’re trying to test, and very often this code is hard to understand if you're not familiar with the implementation of the production code.<br /><br /><b>- Tests can be harder to maintain.</b> When you tell a mock how to behave, you're leaking implementation details of your code into your test. When implementation details in your production code change, you'll need to update your tests to reflect these changes. Tests should typically know little about the code's implementation, and should focus on testing the code's public interface.<br /><br /><b>- Tests can provide less assurance that your code is working properly.</b> When you tell a mock how to behave, the only assurance you get with your tests is that your code will work if your mocks behave exactly like your real implementations. This can be very hard to guarantee, and the problem gets worse as your code changes over time, as the behavior of the real implementations is likely to get out of sync with your mocks.<br /><br />Some signs that you're overusing mocks are if you're mocking out more than one or two classes, or if one of your mocks specifies how more than one or two methods should behave. <b>If you're trying to read a test that uses  mocks and find yourself mentally stepping through the code being tested in order to understand the test,  then you're probably overusing mocks</b>.<br /><br /><b>Sometimes you can't use a real dependency in a test</b> (e.g. if it's too slow or talks over the network), <b>but there may better options than using mocks</b>, such as a hermetic local server (e.g. a credit card server that you start up on your machine specifically for the test) or a fake implementation (e.g. an in-memory credit card server).<br /><br /><i>For more information about using hermetic servers, see <a href="http://googletesting.blogspot.com/2012/10/hermetic-servers.html">http://googletesting.blogspot.com/2012/10/hermetic-servers.html</a>. Stay tuned for a future Testing on the Toilet episode about using fake implementations. </i><br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/uncategorized/testing-on-the-toilet-dont-overuse-mocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>GTAC 2013 Wrap-up</title>
		<link>https://googledata.org/uncategorized/gtac-2013-wrap-up/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gtac-2013-wrap-up</link>
		<comments>https://googledata.org/uncategorized/gtac-2013-wrap-up/#comments</comments>
		<pubDate>Sat, 04 May 2013 16:44:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
		
		<guid isPermaLink="false">https://googledata.org/?guid=4ad9d7b0854336e15db10d8a1c7d3c1c</guid>
		<description><![CDATA[<i>by The GTAC Committee</i><br /><div><br /></div><img border="0" height="180" src="https://developers.google.com/google-test-automation-conference/2013/images/event_thumb/003.jpg">The Google Test Automation Conference (<a href="https://developers.google.com/google-test-automation-conference/">GTAC</a>) was held last week in NYC on April 23rd &#38; 24th. The theme for this year's conference was focused on Mobile and Media. We were fortunate to have a cross section of attendees and presenters from industry and academia. This year&#8217;s talks focused on trends we are seeing in industry combined with compelling talks on tools and infrastructure that can have a direct impact on our products. We believe we achieved a conference that was focused for engineers by engineers. GTAC 2013 demonstrated that there is a strong trend toward the emergence of test engineering as a computer science discipline across companies and academia alike. <br /><div><br /></div><img border="0" height="180" src="https://developers.google.com/google-test-automation-conference/2013/images/event_thumb/044.jpg">All of the <a href="https://developers.google.com/google-test-automation-conference/2013/presentations">slides, video recordings</a>, and <a href="https://developers.google.com/google-test-automation-conference/2013/photos">photos</a> are now available on the GTAC site. Thank you to all the <a href="https://developers.google.com/google-test-automation-conference/2013/speakers">speakers</a> and attendees who made this event spectacular. We are already looking forward to the next GTAC. If you have suggestions for next year&#8217;s location or theme, please comment on this post. To receive GTAC updates, subscribe to the <a href="http://googletesting.blogspot.com/">Google Testing Blog</a>.  <br /><div><br /></div><img border="0" height="180" src="https://developers.google.com/google-test-automation-conference/2013/images/event_thumb/065.jpg">Here are some responses to GTAC 2013: <br /><br /><i>&#8220;My first GTAC, and one of the best conferences of any kind I've ever been to. The talks were consistently great and the chance to interact with so many experts from all over the map was priceless.&#8221;</i> - Gareth Bowles, <a href="http://www.netflix.com/">Netflix</a><br /><br /><i>&#8220;Adding my own thanks as a speaker (and consumer of the material, I learned a lot from the other speakers) -- this was amazingly well run, and had facilities that I've seen many larger conferences not provide. I got everything I wanted from attending and more!&#8221;</i> - James Waldrop, <a href="https://twitter.com/">Twitter</a><br /><br /><i>&#8220;This was a wonderful conference. I learned so much in two days and met some great people. Can't wait to get back to Denver and use all this newly acquired knowledge!&#8221;</i> - Crystal Preston-Watson, <a href="https://www.pingidentity.com/">Ping Identity</a><br /><br /><i>&#8220;GTAC is hands down the smoothest conference/event I've attended. Well done to Google and all involved.&#8221;</i> - Alister Scott, <a href="http://www.thoughtworks.com/">ThoughtWorks</a><br /><br /><i>&#8220;Thanks and compliments for an amazingly brain activity spurring event. I returned very inspired. First day back at work and the first thing I am doing is looking into improving our build automation and speed (1 min is too long. We are not building that much, groovy is dynamic).&#8221;</i> - Irina Muchnik, <a href="http://www.zynxhealth.com/">Zynx Health</a><br /><br />]]></description>
				<content:encoded><![CDATA[<i>by The GTAC Committee</i><br /><div style="clear: both;"><br /></div><img border="0" height="180" src="https://developers.google.com/google-test-automation-conference/2013/images/event_thumb/003.jpg" style="float: left; margin: 0px 10px 10px 0px;" />The Google Test Automation Conference (<a href="https://developers.google.com/google-test-automation-conference/">GTAC</a>) was held last week in NYC on April 23rd &amp; 24th. The theme for this year's conference was focused on Mobile and Media. We were fortunate to have a cross section of attendees and presenters from industry and academia. This year’s talks focused on trends we are seeing in industry combined with compelling talks on tools and infrastructure that can have a direct impact on our products. We believe we achieved a conference that was focused for engineers by engineers. GTAC 2013 demonstrated that there is a strong trend toward the emergence of test engineering as a computer science discipline across companies and academia alike. <br /><div style="clear: both;"><br /></div><img border="0" height="180" src="https://developers.google.com/google-test-automation-conference/2013/images/event_thumb/044.jpg" style="float: right; margin: 0px 0px 10px 10px;" />All of the <a href="https://developers.google.com/google-test-automation-conference/2013/presentations">slides, video recordings</a>, and <a href="https://developers.google.com/google-test-automation-conference/2013/photos">photos</a> are now available on the GTAC site. Thank you to all the <a href="https://developers.google.com/google-test-automation-conference/2013/speakers">speakers</a> and attendees who made this event spectacular. We are already looking forward to the next GTAC. If you have suggestions for next year’s location or theme, please comment on this post. To receive GTAC updates, subscribe to the <a href="http://googletesting.blogspot.com/">Google Testing Blog</a>.  <br /><div style="clear: both;"><br /></div><img border="0" height="180" src="https://developers.google.com/google-test-automation-conference/2013/images/event_thumb/065.jpg" style="float: left; margin: 0px 10px 10px 0px;" />Here are some responses to GTAC 2013: <br /><br /><i>“My first GTAC, and one of the best conferences of any kind I've ever been to. The talks were consistently great and the chance to interact with so many experts from all over the map was priceless.”</i> - Gareth Bowles, <a href="http://www.netflix.com/">Netflix</a><br /><br /><i>“Adding my own thanks as a speaker (and consumer of the material, I learned a lot from the other speakers) -- this was amazingly well run, and had facilities that I've seen many larger conferences not provide. I got everything I wanted from attending and more!”</i> - James Waldrop, <a href="https://twitter.com/">Twitter</a><br /><br /><i>“This was a wonderful conference. I learned so much in two days and met some great people. Can't wait to get back to Denver and use all this newly acquired knowledge!”</i> - Crystal Preston-Watson, <a href="https://www.pingidentity.com/">Ping Identity</a><br /><br /><i>“GTAC is hands down the smoothest conference/event I've attended. Well done to Google and all involved.”</i> - Alister Scott, <a href="http://www.thoughtworks.com/">ThoughtWorks</a><br /><br /><i>“Thanks and compliments for an amazingly brain activity spurring event. I returned very inspired. First day back at work and the first thing I am doing is looking into improving our build automation and speed (1 min is too long. We are not building that much, groovy is dynamic).”</i> - Irina Muchnik, <a href="http://www.zynxhealth.com/">Zynx Health</a><br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/uncategorized/gtac-2013-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>GTAC is Almost Here!</title>
		<link>https://googledata.org/uncategorized/gtac-is-almost-here/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gtac-is-almost-here</link>
		<comments>https://googledata.org/uncategorized/gtac-is-almost-here/#comments</comments>
		<pubDate>Sat, 13 Apr 2013 15:42:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
		
		<guid isPermaLink="false">https://googledata.org/?guid=5898ffb61eeec82ace8e722b22faf752</guid>
		<description><![CDATA[<i>by The GTAC Committee</i><br /><br />GTAC is just around the corner, and we&#8217;re all very busy and excited. I know we say this every year, but this is going to be the best GTAC ever! We have updated the GTAC site with important details:<br /><br /><ul><li><a href="https://developers.google.com/google-test-automation-conference/2013/schedule">The Schedule</a>&#160;</li><li><a href="https://developers.google.com/google-test-automation-conference/2013/speakers">Speaker Profiles</a>&#160;</li><li><a href="https://developers.google.com/google-test-automation-conference/2013/committee">Committee Profiles</a>&#160;</li></ul><br />If you are on the attendance list, we&#8217;ll see you on April 23rd. If not, check out the <a href="https://developers.google.com/google-test-automation-conference/2013/stream">Live Stream</a> page where you can watch the conference live and can get involved in Q&#38;A after each talk. Perhaps your team can gather in a conference room and attend remotely.<br /><br />]]></description>
				<content:encoded><![CDATA[<i>by The GTAC Committee</i><br /><br />GTAC is just around the corner, and we’re all very busy and excited. I know we say this every year, but this is going to be the best GTAC ever! We have updated the GTAC site with important details:<br /><br /><ul><li style="line-height: 1em;"><a href="https://developers.google.com/google-test-automation-conference/2013/schedule">The Schedule</a>&nbsp;</li><li style="line-height: 1em;"><a href="https://developers.google.com/google-test-automation-conference/2013/speakers">Speaker Profiles</a>&nbsp;</li><li style="line-height: 1em;"><a href="https://developers.google.com/google-test-automation-conference/2013/committee">Committee Profiles</a>&nbsp;</li></ul><br />If you are on the attendance list, we’ll see you on April 23rd. If not, check out the <a href="https://developers.google.com/google-test-automation-conference/2013/stream">Live Stream</a> page where you can watch the conference live and can get involved in Q&amp;A after each talk. Perhaps your team can gather in a conference room and attend remotely.<br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/uncategorized/gtac-is-almost-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Two New Videos About Testing at Google</title>
		<link>https://googledata.org/google-testing/two-new-videos-about-testing-at-google/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=two-new-videos-about-testing-at-google</link>
		<comments>https://googledata.org/google-testing/two-new-videos-about-testing-at-google/#comments</comments>
		<pubDate>Fri, 12 Apr 2013 15:13:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
				<category><![CDATA[Google Testing]]></category>

		<guid isPermaLink="false">https://googledata.org/?guid=a889a3dd5940fa0320fe26207a56e0de</guid>
		<description><![CDATA[by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a><br /><br />We have two excellent, new videos to share about testing at Google. If you are curious about the work that our Test Engineers (TEs) and Software Engineers in Test (SETs) do, you&#8217;ll find both of these videos very interesting.<br /><br />The  <a href="http://www.youtube.com/lifeatgoogle">Life at Google</a>  team produced a video series called  <a href="http://www.youtube.com/watch?v=eZHEnPCEe0o&#38;feature=c4-overview-vl&#38;list=PLllx_3tLoo4fd1deqnzvyZrIrJzRdSC6-">Do Cool Things That Matter</a>.  This series includes a video from an SET and TE on the Maps team (Sean Jordan and Yvette Nameth) discussing their work on the Google Maps team.<br /><br /><a href="http://www.youtube.com/watch?v=FcwMMEsRFW4&#38;list=PLllx_3tLoo4fd1deqnzvyZrIrJzRdSC6-">Meet Yvette and Sean from the Google Maps Test Team</a><br /><br /><div></div><br /><br />The  <a href="https://plus.sandbox.google.com/u/0/101571483150813305324">Google Students</a>  team hosted a  <a href="http://www.google.com/+/learnmore/hangouts/onair.html">Hangouts On Air</a>  event with several Google SETs (Diego Salas, Karin Lundberg, Jonathan Velasquez, Chaitali Narla, and Dave Chen)  discussing the SET role.<br /><br /><a href="https://plus.google.com/u/0/101571483150813305324/posts/diXcYNHmMvM">Software Engineers in Test at Google - Covering your (Code)Bases</a><br /><br /><div></div><br /><br />Interested in joining the ranks of TEs or SETs at Google? Search for <a href="http://goo.gl/I0w5J">Google test jobs</a>.<br /><br />]]></description>
				<content:encoded><![CDATA[by <a href="http://www.anthonysapps.com/anthony">Anthony Vallone</a><br /><br />We have two excellent, new videos to share about testing at Google. If you are curious about the work that our Test Engineers (TEs) and Software Engineers in Test (SETs) do, you’ll find both of these videos very interesting.<br /><br />The  <a href="http://www.youtube.com/lifeatgoogle">Life at Google</a>  team produced a video series called  <a href="http://www.youtube.com/watch?v=eZHEnPCEe0o&amp;feature=c4-overview-vl&amp;list=PLllx_3tLoo4fd1deqnzvyZrIrJzRdSC6-">Do Cool Things That Matter</a>.  This series includes a video from an SET and TE on the Maps team (Sean Jordan and Yvette Nameth) discussing their work on the Google Maps team.<br /><br /><a href="http://www.youtube.com/watch?v=FcwMMEsRFW4&amp;list=PLllx_3tLoo4fd1deqnzvyZrIrJzRdSC6-">Meet Yvette and Sean from the Google Maps Test Team</a><br /><br /><div style="text-align: center;"><iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/FcwMMEsRFW4?list=PLllx_3tLoo4fd1deqnzvyZrIrJzRdSC6-" width="560"></iframe></div><br /><br />The  <a href="https://plus.sandbox.google.com/u/0/101571483150813305324">Google Students</a>  team hosted a  <a href="http://www.google.com/+/learnmore/hangouts/onair.html">Hangouts On Air</a>  event with several Google SETs (Diego Salas, Karin Lundberg, Jonathan Velasquez, Chaitali Narla, and Dave Chen)  discussing the SET role.<br /><br /><a href="https://plus.google.com/u/0/101571483150813305324/posts/diXcYNHmMvM">Software Engineers in Test at Google - Covering your (Code)Bases</a><br /><br /><div style="text-align: center;"><iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/OZk8nlcpe3w" width="560"></iframe></div><br /><br />Interested in joining the ranks of TEs or SETs at Google? Search for <a href="http://goo.gl/I0w5J">Google test jobs</a>.<br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/google-testing/two-new-videos-about-testing-at-google/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Testing on the Toilet: Testing State vs. Testing Interactions</title>
		<link>https://googledata.org/uncategorized/testing-on-the-toilet-testing-state-vs-testing-interactions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-on-the-toilet-testing-state-vs-testing-interactions</link>
		<comments>https://googledata.org/uncategorized/testing-on-the-toilet-testing-state-vs-testing-interactions/#comments</comments>
		<pubDate>Sat, 23 Mar 2013 01:48:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
		
		<guid isPermaLink="false">https://googledata.org/?guid=c444a7ca57c2036036f9472e89821427</guid>
		<description><![CDATA[<i>By Andrew Trenk</i><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a printer-friendly <a href="http://goo.gl/8x1Ha">version</a> of this TotT episode and post it in your office.</i><br /><br />There are typically two ways a unit test can verify that the code under test is working properly: by testing state or by testing interactions. What&#8217;s the difference between these?<br /><br /><b>Testing state means you're verifying that the code under test returns the right results.</b><br /><pre>public void testSortNumbers() {<br />  NumberSorter <b>numberSorter</b> = new NumberSorter(<b>quicksort, bubbleSort</b>);<br /><span>// Verify that the returned list is sorted. It doesn't matter which sorting<br />  // algorithm is used, as long as the right result is returned.</span><br />  assertEquals(<br />      new ArrayList(1, 2, 3),<br /><b>numberSorter</b>.sortNumbers(new ArrayList(3, 1, 2)));<br />}</pre><b>Testing interactions means you're verifying that the code under test calls certain methods properly.</b><br /><pre>public void <b>testSortNumbers_quicksortIsUsed</b>() {<br /><span>// Pass in mocks to the class and call the method under test.</span><br />  NumberSorter <b>numberSorter</b> = new NumberSorter(<b>mockQuicksort, mockBubbleSort</b>);<br /><b>numberSorter</b>.sortNumbers(new ArrayList(3, 1, 2));<br /><span>// Verify that numberSorter.sortNumbers() used quicksort. The test should<br />  // fail if mockQuicksort.sort() is never called or if it's called with the<br />  // wrong arguments (e.g. if mockBubbleSort is used to sort the numbers).</span><br />  verify(<b>mockQuicksort</b>).sort(new ArrayList(3, 1, 2));<br />}</pre>The second test may result in good code coverage, but it doesn't tell you whether sorting works properly, only that quicksort.sort() was called. <b>Just because a test that uses interactions is passing doesn't mean the code is working properly</b>. This is why <b>in most cases, you want to test state, not interactions.</b><br />In general, <b>interactions should be tested when correctness doesn't just depend on what the code's output is, but also how the output is determined</b>. In the above example, you would only want to test interactions in addition to testing state if it's important that quicksort is used (e.g. the method would run too slowly with a different sorting algorithm), otherwise the test using interactions is unnecessary. <br /><br /><b>What are some other examples of cases where you want to test interactions?</b><br />- <b>The code under test calls a method where differences in the number or order of calls would cause undesired behavior</b>, such as side effects (e.g. you only want one email to be sent), latency (e.g. you only want a certain number of disk reads to occur) or multithreading issues (e.g. your code will deadlock if it calls some methods in the wrong order). Testing interactions ensures that your tests will fail if these methods aren't called properly. <br />- <b>You're testing a UI where the rendering details of the UI are abstracted away from the UI logic</b> (e.g. using MVC or MVP). In tests for your controller/presenter, you only care that a certain method of the view was called, not what was actually rendered, so you can test interactions with the view. Similarly, when testing the view, you can test interactions with the controller/presenter.]]></description>
				<content:encoded><![CDATA[<i>By Andrew Trenk</i><br /><i>This article was adapted from a <a href="http://googletesting.blogspot.com/2007/01/introducing-testing-on-toilet.html">Google Testing on the Toilet</a> (TotT) episode. You can download a printer-friendly <a href="http://goo.gl/8x1Ha">version</a> of this TotT episode and post it in your office.</i><br /><br />There are typically two ways a unit test can verify that the code under test is working properly: by testing state or by testing interactions. What’s the difference between these?<br /><br /><b>Testing state means you're verifying that the code under test returns the right results.</b><br /><pre style="background: #fffcd0; border: solid 1px #AAAAAA; overflow: auto; padding: 10px;">public void testSortNumbers() {<br />  NumberSorter <b>numberSorter</b> = new NumberSorter(<b>quicksort, bubbleSort</b>);<br />  <span style="color: blue;">// Verify that the returned list is sorted. It doesn't matter which sorting<br />  // algorithm is used, as long as the right result is returned.</span><br />  assertEquals(<br />      new ArrayList(1, 2, 3),<br />      <b>numberSorter</b>.sortNumbers(new ArrayList(3, 1, 2)));<br />}</pre><b>Testing interactions means you're verifying that the code under test calls certain methods properly.</b><br /><pre style="background: #fffcd0; border: solid 1px #AAAAAA; overflow: auto; padding: 10px;">public void <b>testSortNumbers_quicksortIsUsed</b>() {<br />  <span style="color: blue;">// Pass in mocks to the class and call the method under test.</span><br />  NumberSorter <b>numberSorter</b> = new NumberSorter(<b>mockQuicksort, mockBubbleSort</b>);<br />  <b>numberSorter</b>.sortNumbers(new ArrayList(3, 1, 2));<br />  <span style="color: blue;">// Verify that numberSorter.sortNumbers() used quicksort. The test should<br />  // fail if mockQuicksort.sort() is never called or if it's called with the<br />  // wrong arguments (e.g. if mockBubbleSort is used to sort the numbers).</span><br />  verify(<b>mockQuicksort</b>).sort(new ArrayList(3, 1, 2));<br />}</pre>The second test may result in good code coverage, but it doesn't tell you whether sorting works properly, only that quicksort.sort() was called. <b>Just because a test that uses interactions is passing doesn't mean the code is working properly</b>. This is why <b>in most cases, you want to test state, not interactions.</b><br />In general, <b>interactions should be tested when correctness doesn't just depend on what the code's output is, but also how the output is determined</b>. In the above example, you would only want to test interactions in addition to testing state if it's important that quicksort is used (e.g. the method would run too slowly with a different sorting algorithm), otherwise the test using interactions is unnecessary. <br /><br /><b>What are some other examples of cases where you want to test interactions?</b><br />- <b>The code under test calls a method where differences in the number or order of calls would cause undesired behavior</b>, such as side effects (e.g. you only want one email to be sent), latency (e.g. you only want a certain number of disk reads to occur) or multithreading issues (e.g. your code will deadlock if it calls some methods in the wrong order). Testing interactions ensures that your tests will fail if these methods aren't called properly. <br />- <b>You're testing a UI where the rendering details of the UI are abstracted away from the UI logic</b> (e.g. using MVC or MVP). In tests for your controller/presenter, you only care that a certain method of the view was called, not what was actually rendered, so you can test interactions with the view. Similarly, when testing the view, you can test interactions with the controller/presenter.]]></content:encoded>
			<wfw:commentRss>https://googledata.org/uncategorized/testing-on-the-toilet-testing-state-vs-testing-interactions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>Announcing the GTAC 2013 Agenda</title>
		<link>https://googledata.org/uncategorized/announcing-the-gtac-2013-agenda/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=announcing-the-gtac-2013-agenda</link>
		<comments>https://googledata.org/uncategorized/announcing-the-gtac-2013-agenda/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 01:46:00 +0000</pubDate>
		<dc:creator><![CDATA[Google Testing Bloggers]]></dc:creator>
		
		<guid isPermaLink="false">https://googledata.org/?guid=fc46e8c8e5d448ea656640d4f28521a1</guid>
		<description><![CDATA[<br /><span>by The GTAC Committee</span><br /><span><br /></span><span>We have completed selection and confirmation of all speakers for GTAC 2013. You can find the detailed agenda at:</span><br /><span>&#160; <a href="http://developers.google.com/gtac/2013/schedule">developers.google.com/gtac/2013/schedule</a></span><br /><span><br /></span><span>Thank you to all who submitted proposals! It was very hard to make selections from so many fantastic submissions.</span><br /><span><br /></span><span>If you were not extended an invitation, don&#8217;t forget that you can join us via YouTube live streaming. We&#8217;ll be setting up <a href="http://www.google.com/moderator/">Google Moderator</a>, so remote attendees can get involved in Q&#38;A after each talk. Information about live streaming, Moderator, and other details will be posted on the GTAC site soon and announced here.</span><br /><br />]]></description>
				<content:encoded><![CDATA[<br /><span style="font-family: Arial, Helvetica, sans-serif;">by The GTAC Committee</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">We have completed selection and confirmation of all speakers for GTAC 2013. You can find the detailed agenda at:</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp; <a href="http://developers.google.com/gtac/2013/schedule">developers.google.com/gtac/2013/schedule</a></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Thank you to all who submitted proposals! It was very hard to make selections from so many fantastic submissions.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">If you were not extended an invitation, don’t forget that you can join us via YouTube live streaming. We’ll be setting up <a href="http://www.google.com/moderator/">Google Moderator</a>, so remote attendees can get involved in Q&amp;A after each talk. Information about live streaming, Moderator, and other details will be posted on the GTAC site soon and announced here.</span><br /><br />]]></content:encoded>
			<wfw:commentRss>https://googledata.org/uncategorized/announcing-the-gtac-2013-agenda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
	</channel>
</rss>
