<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>[Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx</link><description>My latest MSDN Magazine article titled " Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears " is out in the online January Issue here. It's based on real issues, guidelines I've developed and questions I've encountered</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: [Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx#433311</link><pubDate>Fri, 16 Dec 2005 12:38:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:433311</guid><dc:creator>Rui Quintino</dc:creator><author>Rui Quintino</author><description>Great article Roy (as usual) :)&lt;br&gt;&lt;br&gt;One thing I was thinking about, on multiple asserts. I mostly agree with the single assert per test, but sometimes I feel that we're just not using multiple asserts because the framework simply doesn't support that, and no other &amp;quot;best practice&amp;quot; reason.&lt;br&gt;&lt;br&gt;Why not supporting code like:&lt;br&gt;&lt;br&gt;AssertGroup agroup= new AssertGroup();&lt;br&gt;&lt;br&gt;agroup.add(new AssertEqual(...));&lt;br&gt;agroup.add(new AssertNotNull(...));&lt;br&gt;....&lt;br&gt;agroup.AssertAll()&lt;br&gt;&lt;br&gt;Could this reduce some test code? Probably. Is it a good ideia? Don't know yet.&lt;br&gt;&lt;br&gt;Another possible conclusion is that, currently, the feedback we get from tests is very limited (to a failed single assert).&lt;br&gt;&lt;br&gt;Anyway, just some lost thoughts. :)&lt;br&gt;&lt;br&gt;RQ&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=433311" width="1" height="1"&gt;</description></item><item><title>re: [Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx#433254</link><pubDate>Thu, 15 Dec 2005 20:39:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:433254</guid><dc:creator>Nikolai</dc:creator><author>Nikolai</author><description>Great thanks for the tips Roy&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=433254" width="1" height="1"&gt;</description></item><item><title>re: [Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx#433158</link><pubDate>Wed, 14 Dec 2005 21:55:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:433158</guid><dc:creator>Roy Osherove</dc:creator><author>Roy Osherove</author><description>Nikolai: You're calling the other test because you'd like to share the same setup between the tests, but you're not only creating a dependency, you're also essentially running two tests (two asserts will take place).&lt;br&gt;Instead, refactor the common setup code in the original test you're running (which you are calling from the 2nd test) into a utility method which is in the same class. Both tests will call that method when they begin, but that way each test is free of dependencies.&lt;br&gt;If all the tests in the class need this common code feel free to put that share setup call in the [setup] method.&lt;br&gt;&lt;br&gt;If it's a DB setup code you may want to either use setup scripts, or you can use the enterprise services rollback method I describe in my other article relating to DB unit testing :&lt;br&gt;&lt;a target="_new" href="http://msdn.microsoft.com/msdnmag/issues/05/06/UnitTesting/"&gt;http://msdn.microsoft.com/msdnmag/issues/05/06/UnitTesting/&lt;/a&gt;&lt;br&gt;&lt;br&gt;Hope this helps,&lt;br&gt;Roy.&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=433158" width="1" height="1"&gt;</description></item><item><title>re: [Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx#433150</link><pubDate>Wed, 14 Dec 2005 20:04:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:433150</guid><dc:creator>Nikolai</dc:creator><author>Nikolai</author><description>Roy you mention in your article that you should &amp;quot;Avoid Dependencies Between Tests&amp;quot;. I sometimes call one test from another to ensure that data/state is setup for this test to run. It does require that the other test is run before hand, but I guess it does create a dependency between the two.&lt;br&gt;&lt;br&gt;What do you think is a better alternative to this? Like a database setup and tear down scripts for the test suite? Or to use the setup teardown sections of the test to seutp this data?&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=433150" width="1" height="1"&gt;</description></item><item><title>re: [Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx#433090</link><pubDate>Wed, 14 Dec 2005 08:57:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:433090</guid><dc:creator>Roy Osherove</dc:creator><author>Roy Osherove</author><description>Eber: I was expressly using a simple example, since the rules aply to tests of any level of complexity. If you'd like data related examples, I have an article specifically about that, linked to my this article.&lt;br&gt;&lt;a target="_new" href="http://msdn.microsoft.com/msdnmag/issues/05/06/UnitTesting/"&gt;http://msdn.microsoft.com/msdnmag/issues/05/06/UnitTesting/&lt;/a&gt;&lt;br&gt;&lt;br&gt;Can you elaborate what kind of guidelines you'd like to see that are not covered?&lt;br&gt;I'd love to see what I should be concentrating on.&lt;br&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=433090" width="1" height="1"&gt;</description></item><item><title>re: [Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx#433087</link><pubDate>Wed, 14 Dec 2005 08:20:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:433087</guid><dc:creator>Dan Bunea</dc:creator><author>Dan Bunea</author><description>Hi,&lt;br&gt;&lt;br&gt;Test code organization can be a problem just as big as the code organization can be and poiting out rules that apply to test code organization to make it bug free, useful, self explaining and maintanable is a great thing you did.&lt;br&gt;&lt;br&gt;There is also another great resource about test code organization, patterns and smells at: www.testautomationpatterns.com&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;Dan Bunea&lt;br&gt;&lt;a target="_new" href="http://danbunea.blogspot.com"&gt;http://danbunea.blogspot.com&lt;/a&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=433087" width="1" height="1"&gt;</description></item><item><title>re: [Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx#433067</link><pubDate>Tue, 13 Dec 2005 20:41:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:433067</guid><dc:creator>SBC</dc:creator><author>SBC</author><description>congratulations Roy! It's definitely on my reading list in the near coming days..&lt;br&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=433067" width="1" height="1"&gt;</description></item><item><title>re: [Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx#433060</link><pubDate>Tue, 13 Dec 2005 18:54:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:433060</guid><dc:creator>Eber  Irigoyen</dc:creator><author>Eber  Irigoyen</author><description>I was expecting something more than a test for a sum, there are many people that talk about TDD, but very few show actual code for more complicated scenarios, specially when using data (databases, xml, whatever files, etc), or how you separate the test code from the production code, etc&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=433060" width="1" height="1"&gt;</description></item><item><title>re: [Article] Unit Testing Tips - Write Maintainable Unit Tests That Will Save You Time And Tears</title><link>http://weblogs.asp.net/rosherove/archive/2005/12/13/UnitTestingTipsArticleIsOnline.aspx#433057</link><pubDate>Tue, 13 Dec 2005 18:11:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:433057</guid><dc:creator>Joshua Flanagan</dc:creator><author>Joshua Flanagan</author><description>I've been meaning to blog about this article, to recommend it to everyone starting out with TDD (but since you get a lot more traffic than I do, why not write it here will people will actually see it?).&lt;br&gt;&lt;br&gt;You really did a fine job of capturing the common gotchas, and giving good guidance for how to approach writing your tests. A lot of other sources tell you &amp;quot;what&amp;quot; and &amp;quot;why&amp;quot;, but its tough to find a good source on &amp;quot;how&amp;quot;.  This is it.  Thanks a lot!&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=433057" width="1" height="1"&gt;</description></item></channel></rss>