<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Android Functional Testing vs Dependency Injection</title>
	<atom:link href="http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/</link>
	<description>A man needs a little madness, or else he never dares cut the rope and be free. -Nikos Kazantzakis</description>
	<lastBuildDate>Fri, 03 Feb 2012 00:04:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Maks</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-469181</link>
		<dc:creator>Maks</dc:creator>
		<pubDate>Wed, 11 Jan 2012 00:05:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-469181</guid>
		<description>Thanks for the great pattern, its a perfect fit for use in simple android apps and exactly what I was after without going the heavy weight route of using roboguice.</description>
		<content:encoded><![CDATA[<p>Thanks for the great pattern, its a perfect fit for use in simple android apps and exactly what I was after without going the heavy weight route of using roboguice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-436362</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 22 Nov 2011 12:16:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-436362</guid>
		<description>This post just blew my mind. As a newb Android developer (two months) I have been looking for a good way to do this. This is awesome!

Thanks for the wonderful post!</description>
		<content:encoded><![CDATA[<p>This post just blew my mind. As a newb Android developer (two months) I have been looking for a good way to do this. This is awesome!</p>
<p>Thanks for the wonderful post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-418379</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Wed, 19 Oct 2011 16:36:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-418379</guid>
		<description>You can actually make it work with instance rather than static fields if the test uses getInstrumentation().getTargetContext().getApplicationContext() to get a reference to the application object.</description>
		<content:encoded><![CDATA[<p>You can actually make it work with instance rather than static fields if the test uses getInstrumentation().getTargetContext().getApplicationContext() to get a reference to the application object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-393011</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Wed, 07 Sep 2011 03:30:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-393011</guid>
		<description>I use a similar pattern although I initialise the service to the default impl as required via null check and just use the setter in the tests.
However, my issue is that my fake service is providing an alternative data set which cannot be browsed via the running app (when conceiving a new test) without the app knowing about the fake class.. which it doesn&#039;t because it resides in the test application, not the application.  Do you know how to run the android app in &quot;test mode&quot; .. ie, as you would see it when the unit tests are run against the fake service?</description>
		<content:encoded><![CDATA[<p>I use a similar pattern although I initialise the service to the default impl as required via null check and just use the setter in the tests.<br />
However, my issue is that my fake service is providing an alternative data set which cannot be browsed via the running app (when conceiving a new test) without the app knowing about the fake class.. which it doesn&#8217;t because it resides in the test application, not the application.  Do you know how to run the android app in &#8220;test mode&#8221; .. ie, as you would see it when the unit tests are run against the fake service?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Leach</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-319668</link>
		<dc:creator>Tom Leach</dc:creator>
		<pubDate>Sun, 17 Apr 2011 18:25:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-319668</guid>
		<description>Great pattern! Having come from an enterprise background and being used to making heavy use of DI I was a bit dismayed to find out how coupled android application classes seem to be to the underlying API via inheritance. 

I had considered roboguice as a possibility but I don&#039;t like the way it makes you use their testing framework classes. 

Using a centralised service locator seems like a good pragmatic alternative. I&#039;ll give it a go.</description>
		<content:encoded><![CDATA[<p>Great pattern! Having come from an enterprise background and being used to making heavy use of DI I was a bit dismayed to find out how coupled android application classes seem to be to the underlying API via inheritance. </p>
<p>I had considered roboguice as a possibility but I don&#8217;t like the way it makes you use their testing framework classes. </p>
<p>Using a centralised service locator seems like a good pragmatic alternative. I&#8217;ll give it a go.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yoshihiro</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-281932</link>
		<dc:creator>Yoshihiro</dc:creator>
		<pubDate>Thu, 13 Jan 2011 06:07:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-281932</guid>
		<description>Hi.

I tried to inject to Activity by using guice2.0_no_AOP.I didn&#039;t use roboguice.

I could inject by field static injection like following.

//MyActivity
public class MyActivity ...
@Inject static private Service service;

//in guice Module
Protected void configure() {
bind(Service.class).to(ServiceImpl.class);
requestStaticInjection(MyActivity.class);
}

But when I write test, using this method let me write another Module for test and make injector instance in testing code.

Do you think which one is easier?</description>
		<content:encoded><![CDATA[<p>Hi.</p>
<p>I tried to inject to Activity by using guice2.0_no_AOP.I didn&#8217;t use roboguice.</p>
<p>I could inject by field static injection like following.</p>
<p>//MyActivity<br />
public class MyActivity &#8230;<br />
@Inject static private Service service;</p>
<p>//in guice Module<br />
Protected void configure() {<br />
bind(Service.class).to(ServiceImpl.class);<br />
requestStaticInjection(MyActivity.class);<br />
}</p>
<p>But when I write test, using this method let me write another Module for test and make injector instance in testing code.</p>
<p>Do you think which one is easier?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Laing</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-278351</link>
		<dc:creator>David Laing</dc:creator>
		<pubDate>Mon, 03 Jan 2011 20:51:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-278351</guid>
		<description>Jason,

Amazing - a pattern that usually gets me in trouble is exactly right for a simple Android app.

Thanks for bringing it to my attention (again)

David</description>
		<content:encoded><![CDATA[<p>Jason,</p>
<p>Amazing &#8211; a pattern that usually gets me in trouble is exactly right for a simple Android app.</p>
<p>Thanks for bringing it to my attention (again)</p>
<p>David</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-226182</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 13 Jul 2010 11:48:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-226182</guid>
		<description>Hi Miguel,

Thanks for the kind feedback.  Re: testing preferences, you are correct that if you use ActivityInstrumentationTestCase2 you get a real context and changes to the preferences will persist.  Actually in my example I use an interface (ISettings) in between the preferences and my activity under test.  In my case this is to make it easy for me to fake different preferences without changing the underlying persistent data.  You could extend this idea to allow settings to be changed via the ISettings interface, and test your activity makes the intended updates in that way.</description>
		<content:encoded><![CDATA[<p>Hi Miguel,</p>
<p>Thanks for the kind feedback.  Re: testing preferences, you are correct that if you use ActivityInstrumentationTestCase2 you get a real context and changes to the preferences will persist.  Actually in my example I use an interface (ISettings) in between the preferences and my activity under test.  In my case this is to make it easy for me to fake different preferences without changing the underlying persistent data.  You could extend this idea to allow settings to be changed via the ISettings interface, and test your activity makes the intended updates in that way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miguel</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-226162</link>
		<dc:creator>Miguel</dc:creator>
		<pubDate>Tue, 13 Jul 2010 10:47:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-226162</guid>
		<description>Hi,

have you tested any Activity that made changes on the preferences? In my tests, the changes were persistent, which is something I obviously don&#039;t want. I&#039;m still new to android world, but my guess is that getContext() returns the real context of the application rather than a mock/fake one.

Thanks a lot for the android related posts, they are well written and formative. I added you to my reader.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>have you tested any Activity that made changes on the preferences? In my tests, the changes were persistent, which is something I obviously don&#8217;t want. I&#8217;m still new to android world, but my guess is that getContext() returns the real context of the application rather than a mock/fake one.</p>
<p>Thanks a lot for the android related posts, they are well written and formative. I added you to my reader.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/comment-page-1/#comment-223643</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 30 Jun 2010 00:08:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654#comment-223643</guid>
		<description>Hi Dom,

Thanks for the tip: I&#039;ll have to check out android-mock.</description>
		<content:encoded><![CDATA[<p>Hi Dom,</p>
<p>Thanks for the tip: I&#8217;ll have to check out android-mock.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

