<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Software Creations - Orn Kristjansson</title>
	
	<link>http://kristjansson.us</link>
	<description>Agile development and software thingies</description>
	<pubDate>Sat, 31 Jul 2010 14:48:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SoftwareCreations-OrnKristjansson" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="softwarecreations-ornkristjansson" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Selenium browser UnitTesting from TeamCity</title>
		<link>http://kristjansson.us/?p=947</link>
		<comments>http://kristjansson.us/?p=947#comments</comments>
		<pubDate>Fri, 30 Jul 2010 22:32:45 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[.net]]></category>

		<category><![CDATA[Agile]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Nant]]></category>

		<category><![CDATA[Networking]]></category>

		<category><![CDATA[TeamCity]]></category>

		<category><![CDATA[UnitTest]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[selenium]]></category>

		<category><![CDATA[browser]]></category>

		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=947</guid>
		<description><![CDATA[I just setup browser testing framework utilizing Selenium from TeamCity project.  The usual suspects are involved, Gallio, MBUnit, Nant and even C# Unittests.
The usual scenario when it comes to automating browser testing is that the QA / testers will create some scripts to run a browser against your website.  Somehow those tests are [...]]]></description>
			<content:encoded><![CDATA[<p>I just setup browser testing framework utilizing Selenium from TeamCity project.  The usual suspects are involved, Gallio, MBUnit, Nant and even C# Unittests.</p>
<p>The usual scenario when it comes to automating browser testing is that the QA / testers will create some scripts to run a browser against your website.  Somehow those tests are usually not maintained very well and  often are run by hand.  There is not much value in browser testing scripts if you have to run them by hand.  </p>
<p>As I needed browser testing on one of the projects I&#8217;m on I decided to look into using more of a automated setup to run the browser tests.  There seem to be two big players Waitn and Selenium, Selenium lends itself to broader range of testing, naturally we will go with Selenium.</p>
<p>Here is the scenario I want, the tester installs a recorder on his computer, in this case a FireFox plugin.  The tester records the tests and runs them in the browser using the plugin tool.  Once the tester is happy with the tests the tester checks them into the repository.  After check-in tester lets a developer know that there are new or changed tests.  The developer takes the script and turns it into C# UnitTest, simply has Selenium convert it to UnitTest code.  Then the developer takes and updates or adds the tests that resulted from the scripts and checks it into the repository.  The conversion step could be automated in the future once Selenium supports that.  The next step is to run it from TeamCity and after it runs you get email with the results.</p>
<p>So let&#8217;s take a closer look at what is needed.  We need the UnitTest to be able to run against different servers using different browsers.  We will pass values from TeamCity to the Nant script that is responsible for compiling and running the tests.  This is how your test C# configuration file might look like. </p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="coMULTI">&lt;!&#8211; Selenium RC properties&#8211;&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">key</span>=<span class="st0">&#8220;SeleniumAddress&#8221;</span> <span class="re0">value</span>=<span class="st0">&#8220;localhost&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">key</span>=<span class="st0">&#8220;SeleniumPort&#8221;</span> <span class="re0">value</span>=<span class="st0">&#8220;4444&#8243;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">key</span>=<span class="st0">&#8220;SeleniumSpeed&#8221;</span> <span class="re0">value</span>=<span class="st0">&#8220;0&#8243;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="sc3"><span class="coMULTI">&lt;!&#8211; Browser targets &#8211;&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">key</span>=<span class="st0">&#8220;BrowserType&#8221;</span> <span class="re0">value</span>=<span class="st0">&#8220;*firefox&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">key</span>=<span class="st0">&#8220;BrowserUrl&#8221;</span> <span class="re0">value</span>=<span class="st0">&#8220;http://10.9.169.198/&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">key</span>=<span class="st0">&#8220;BaseUrlPath&#8221;</span> <span class="re0">value</span>=<span class="st0">&#8220;IPCA.Dev/&#8221;</span> <span class="re2">/&gt;</span></span></div>
</div>
<p>Then the base test class will look something like this.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="br0">&#91;</span>FixtureSetUp<span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <span class="kw1">virtual</span> <span class="kw1">void</span> TestFixtureSetup<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Read from config </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msBrowserType = getConfigSetting<span class="br0">&#40;</span><span class="st0">&#8220;BrowserType&#8221;</span>, msBrowserType <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msBrowserUrl = getConfigSetting<span class="br0">&#40;</span><span class="st0">&#8220;BrowserUrl&#8221;</span>, msBrowserUrl<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msBasePath = getConfigSetting<span class="br0">&#40;</span><span class="st0">&#8220;BaseUrlPath&#8221;</span>, msBasePath<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msSeleniumAddress = getConfigSetting<span class="br0">&#40;</span> <span class="st0">&#8220;SeleniumAddress&#8221;</span>, msSeleniumAddress <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; miSeleniumPort = <span class="kw4">int</span>.<span class="me1">Parse</span><span class="br0">&#40;</span>getConfigSetting<span class="br0">&#40;</span><span class="st0">&#8220;SeleniumPort&#8221;</span>, miSeleniumPort.<span class="me1">ToString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msSeleniumSpeed = getConfigSetting<span class="br0">&#40;</span> <span class="st0">&#8220;SeleniumSpeed&#8221;</span>, msSeleniumSpeed <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Start up the selenium session, using config values</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> DefaultSelenium<span class="br0">&#40;</span>msSeleniumAddress, miSeleniumPort, msBrowserType, msBrowserUrl<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">Start</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Clean errors</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verificationErrors = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> StringBuilder<span class="br0">&#40;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// sets the speed of execution of GUI commands</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">SetSpeed</span><span class="br0">&#40;</span>msSeleniumSpeed<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>TearDown<span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <span class="kw1">void</span> TeardownTest<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">Stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">catch</span> <span class="br0">&#40;</span>Exception<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Ignore errors if unable to close the browser</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert.<span class="me1">AreEqual</span><span class="br0">&#40;</span><span class="st0">&#8220;&#8221;</span>, verificationErrors.<span class="me1">ToString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</div>
<p>And a sample Selenium C# Unittest </p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">//</span><br />
<span class="kw1">using</span> <span class="kw5">System</span>;<br />
<span class="kw1">using</span> <span class="kw5">System</span>.<span class="me1">Text</span>;<br />
<span class="kw1">using</span> <span class="kw5">System</span>.<span class="me1">Text</span>.<span class="me1">RegularExpressions</span>;<br />
<span class="kw1">using</span> <span class="kw5">System</span>.<span class="me1">Threading</span>;<br />
<span class="co1">//</span><br />
<span class="kw1">using</span> Gallio.<span class="me1">Framework</span>.<span class="me1">Assertions</span>;<br />
<span class="kw1">using</span> MbUnit.<span class="me1">Framework</span>;<br />
<span class="co1">//</span><br />
<span class="kw1">using</span> Selenium;</p>
<p><span class="kw1">namespace</span> SeleniumTests<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>TestFixture<span class="br0">&#93;</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">class</span> LoginPage : WebTestBase<br />
&nbsp; &nbsp; <span class="br0">&#123;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>Test<span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <span class="kw1">void</span> TheLoginPageTest<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">Open</span><span class="br0">&#40;</span> <span class="kw1">this</span>.<span class="me1">msBasePath</span> + <span class="st0">&#8220;TestLogin.aspx&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">Click</span><span class="br0">&#40;</span><span class="st0">&#8220;lbAdmin&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">WaitForPageToLoad</span><span class="br0">&#40;</span><span class="st0">&#8220;50000&#8243;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">Click</span><span class="br0">&#40;</span><span class="st0">&#8220;loginLink&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">WaitForPageToLoad</span><span class="br0">&#40;</span><span class="st0">&#8220;50000&#8243;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert.<span class="me1">IsTrue</span><span class="br0">&#40;</span>selenium.<span class="me1">IsTextPresent</span><span class="br0">&#40;</span><span class="st0">&#8220;my responsibilities regarding permissible access&#8221;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">catch</span> <span class="br0">&#40;</span>AssertionException e<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verificationErrors.<span class="me1">Append</span><span class="br0">&#40;</span>e.<span class="me1">Message</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">Click</span><span class="br0">&#40;</span><span class="st0">&#8220;ctl00_pageContent_btnSubmit&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selenium.<span class="me1">WaitForPageToLoad</span><span class="br0">&#40;</span><span class="st0">&#8220;50000&#8243;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert.<span class="me1">IsTrue</span><span class="br0">&#40;</span>selenium.<span class="me1">IsTextPresent</span><span class="br0">&#40;</span><span class="st0">&#8220;Total Unassigned Web&#8221;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">catch</span> <span class="br0">&#40;</span>AssertionException e<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verificationErrors.<span class="me1">Append</span><span class="br0">&#40;</span>e.<span class="me1">Message</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>After the Nant script compiles the tests and is getting ready to run the UnitTests it needs to startup the Selenium engine.  Make sure to spawn in order for the Selenium engine to exist on another thread than your tests.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&#8220;SeleniumExec&#8221;</span> <span class="re0">value</span>=<span class="st0">&#8220;java&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&#8220;SeleniumPath&#8221;</span> <span class="re0">value</span>=<span class="st0">&#8220;C:<span class="es0">\a</span>pps<span class="es0">\s</span>elenium<span class="es0">\s</span>elenium-server-1.0.3<span class="es0">\&#8221;</span> /&gt;</span><br />
&nbsp; <span class="sc3">&lt;property name=&#8221;</span>SeleniumParams<span class="st0">&#8221; value=&#8221;</span>-jar $<span class="br0">&#123;</span>SeleniumPath<span class="br0">&#125;</span>selenium-server.jar<span class="st0">&#8221; /&gt;</span></p>
<p>
&nbsp; &nbsp; <span class="sc3">&lt;!&#8211; Start selenium &#8211;&gt;</span><br />
&nbsp; &nbsp; <span class="sc3">&lt;exec&nbsp; &nbsp;program=&#8221;</span>$<span class="br0">&#123;</span>SeleniumExec<span class="br0">&#125;</span><span class="st0">&#8220;<br />
&nbsp; &nbsp; &nbsp; commandline=&#8221;</span>$<span class="br0">&#123;</span>SeleniumParams<span class="br0">&#125;</span><span class="st0">&#8221; workingdir=&#8221;</span>$<span class="br0">&#123;</span>path.base<span class="br0">&#125;</span>$<span class="br0">&#123;</span>WebTest<span class="br0">&#125;</span><span class="st0">&#8220;<br />
&nbsp; &nbsp; &nbsp; spawn=&#8221;</span>true<span class="st0">&#8221; failonerror=&#8221;</span>true<span class="st0">&#8221; verbose=&#8221;</span>true<span class="st0">&#8220;<br />
&nbsp; &nbsp; &nbsp; &nbsp;/&gt;</span></p>
<p>&nbsp; &nbsp; <span class="sc3">&lt;!&#8211; Give it a sec to load &#8211;&gt;</span><br />
&nbsp; &nbsp; <span class="sc3">&lt;sleep milliseconds=&#8221;</span>3000<span class="st0">&#8221; /&gt;</span> </span></div>
</div>
<p>In order to run the tests using different browsers, change the configuration file of the tests before run.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="coMULTI">&lt;!&#8211; Run tests in Firefox browser &#8211;&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;xmlpoke</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">file</span>=<span class="st0">&#8220;${path.base.test}${assembly.test.config}&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">xpath</span>=<span class="st0">&#8220;/configuration/appSettings/add[@key='BrowserType']/@value&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">value</span>=<span class="st0">&#8220;*firefox&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">verbose</span>=<span class="st0">&#8220;true&#8221;</span><span class="re2">/&gt;</span></span></p>
<p>&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;call</span> <span class="re0">target</span>=<span class="st0">&#8220;runTests&#8221;</span> <span class="re2">/&gt;</span></span></p>
<p><span class="sc3"><span class="re1">&lt;target</span> <span class="re0">name</span>=<span class="st0">&#8220;runTests&#8221;</span> <br />
&nbsp; &nbsp; <span class="re0">description</span>=<span class="st0">&#8220;runs tests using Gallio.&#8221;</span> <span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;*** Start runTests: &#8220;</span><span class="re2">/&gt;</span></span></p>
<p>&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;gallio</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">result-property</span>=<span class="st0">&#8220;exitCode&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">failonerror</span>=<span class="st0">&#8220;false&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">report-types</span>=<span class="st0">&#8220;Html;Xml&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">report-directory</span>=<span class="st0">&#8220;${artifacts}&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">report-name-format</span>=<span class="st0">&#8220;gallioresults&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">show-reports</span>=<span class="st0">&#8220;false&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">application-base-directory</span>=<span class="st0">&#8220;${path.base.test}&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="coMULTI">&lt;!&#8211; Specify the tests assemblies&nbsp; &#8211;&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;files<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;include</span> <span class="re0">name</span>=<span class="st0">&#8220;${path.base.test}${assembly.test}&#8221;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/files<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/gallio<span class="re2">&gt;</span></span></span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="coMULTI">&lt;!&#8211; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set error for email injector to pick it up and GlobalFailBuildMessage for <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; the end target to fail the build after cleanup<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211;&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;if</span> <span class="re0">test</span>=<span class="st0">&#8220;${int::parse(exitCode)!=0}&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&#8220;GlobalFailBuildMessage&#8221;</span> <span class="re0">value</span>=<span class="st0">&#8220;*** One or more tests failed. Please check the log for more details&#8221;</span> <span class="re0">dynamic</span>=<span class="st0">&#8220;true&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;EmailInjectMsg=${GlobalFailBuildMessage}&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/if<span class="re2">&gt;</span></span></span></p>
<p>&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;*** End runTests: &#8220;</span><span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/target<span class="re2">&gt;</span></span></span></div>
</div>
<p>And after the run of the Unittests Selenium needs to be shut down </p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="coMULTI">&lt;!&#8211; Stop Selenium server &#8211;&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;get</span>&nbsp; <span class="re0">src</span>=<span class="st0">&#8220;http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">dest</span>=<span class="st0">&#8220;shutdown.txt&#8221;</span>&nbsp; <span class="re0">failonerror</span>=<span class="st0">&#8220;false&#8221;</span> <br />
&nbsp; &nbsp; &nbsp; <span class="re2">/&gt;</span></span></div>
</div>
<p>As I had a need to setup different configurations in TeamCity to run against different locations on the webserver I used a couple of Nant variables that are passed on the command line from TeamCity, like you normally would do when running Nant script  -D:BaseUrlPath=/Test/ etc.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;*** Location variables passed from TeamCity&#8221;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;*** BrowserUrl=${BrowserUrl} &#8220;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;*** BaseUrlPath=${BaseUrlPath} &#8220;</span><span class="re2">/&gt;</span></span></div>
</div>
<p>Of course you get the Gallio UnitTest report as well </p>
<p><img src="http://kristjansson.us/wp-content/uploads/2010/07/gallio_report.jpg" alt="gallio_report" title="gallio_report" width="503" height="618" class="alignnone size-full wp-image-963" /></p>
<p>With this setup once we deploy to a server we can run all the browser tests on it using different browsers with one click of a button from TeamCity.</p>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=947</wfw:commentRss>
		</item>
		<item>
		<title>#swBoulder 2010 - Startup Weekend</title>
		<link>http://kristjansson.us/?p=912</link>
		<comments>http://kristjansson.us/?p=912#comments</comments>
		<pubDate>Sun, 25 Apr 2010 23:37:33 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Events]]></category>

		<category><![CDATA[Networking]]></category>

		<category><![CDATA[startup]]></category>

		<category><![CDATA[swboulder]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=912</guid>
		<description><![CDATA[What does the #swBoulder hashtag stand for you may ask.  sw stands for Startup Weekend the one I attended last weekend was held in Boulder they are held all over the country and in other countries well.  Andrew Hyde is the founder of Startup Weekend and so much more, check him out.
Let me [...]]]></description>
			<content:encoded><![CDATA[<p>What does the #swBoulder hashtag stand for you may ask.  sw stands for <a href="http://startupweekend.org/about/">Startup Weekend</a> the one I attended last weekend was held in Boulder they are held all over the country and in other countries well.  <a href="http://andrewhy.de/">Andrew Hyde</a> is the founder of Startup Weekend and so much more, check him out.</p>
<p>Let me give you first a little bit of information what it is all about.  Simply work in startup mode for a weekend on a project of your choice and see what you can produce with your team.  It&#8217;s a event geared towards technology / software, however you don&#8217;t have to be developer.  Most of the teams are made up of people with different backgrounds marketing, sales, business, developers and other skills as well.  Everybody brings something to the table, it doesn&#8217;t matter what it is.  If you like to contribute to a project in a startup settings this event is for you.  Don&#8217;t worry about what you can do or what you can not do, there is room for everybody and everybody contributes.  Some of the people working on the project do not have time to stay for the whole weekend that is fine as well, you contribute what you can.  Of course it&#8217;s best to give the lead that information up front in order for the lead to know how you can be used as a resource over the course of the weekend.</p>
<p>And here is how it went down for me.  The event was held at CU Leeds School of Business, people started gathering in around 17:00 on Friday.  There was pizza and beer, the usual menu that most people can deal with.  To kick it off <a href="http://www.cameronburgess.org/">Cameron Burgess</a> and then <a href="http://twitter.com/heyrich">Rich Grote</a> ( SnapImpact ) had entertaining and informative talks to set the tone for the event.<br />
Next up those who had an idea that they wanted to pitch got the stage for 5 minutes each.  I did have an idea of my own but decided not to push it as the crowd of 40-50 people ended up with 13 ideas presented, there was plenty to choose from.  Next the crowd voted on the ideas, which ones were to be worked on over the weekend, 8 of those were chosen.  At this point you had to choose which idea you wanted to work on.  There were two ideas I liked and I talked to both presenters then chose <a href="http://twitter.com/lloyddobbler">lloyddobllers</a> idea from there.  As the groups start to form the people in the group start figuring out plan of attack and take ownership of different aspects of what needs to be done.  This is your opportunity to work on something that you feel is exciting or new.  At this point our group broke up and we started poking at what needed to be done each in our own corners, I had an Avalanche game to watch and did not get much done rest of the night.  We figured we would show up around 9 on Saturday morning.</p>
<p>Saturday morning we showed up early ready to work going as fast as we could.  As in a normal startup, time is of essence and things move quickly, just keep going.  For lunch <a href="http://twitter.com/yush">Ayush Agarwal</a> came by and had a talk about Startup Weekend and gave some tips about what the judges are looking for which benefited us greatly and then took questions.  Then back to work, before you know it it&#8217;s getting close to midnight.  We actually made the mistake of forgetting to have dinner and were running pretty low when we headed home for the night.  Home to get some food and recharge the  batteries.</p>
<p>Sunday morning after some hours of sleep we showed up again ready to rock it for the rest of the day.  We really wanted to ship a product before the end of the day.  It was recommended to us to ship on Saturday night, but how could we, we had plenty of hours to work in more features on Sunday.  Along with a prototype of the application we put together a business plan and a slide presentation.  Even a promotional video was made along the way.  As expected it came down to the wire on the development side, we wanted certain features and finished up with 20 minutes to spare.  we demoed the website live on our own domain during our presentation, no crashes&#8230; <img src='http://kristjansson.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>During the presentations, the judges got busy both with questions and forming their opinions of the projects.  6 out of 8 projects made it to the finish line, props goes to one of the teams which lost all but two of their people through the course of the weekend but still presented a viable idea, way to stick with it.  Apparently our project kicked ass and was chosen the best one by the judges.  That was the icing on the cake for our hard work through the weekend, but regardless I think we would have been very proud of what produced regardless of what place we ended up at.  Not only was the idea business viable but we managed to ship, have a good business plan, presentation, live demo of the product and exit strategy  we even signed up couple of partners along the way.</p>
<p>In my case I had never done Twitter <a href="http://apiwiki.twitter.com/OAuth-FAQ">OAuth</a> authentication and offered to work on that, now I know how that works.  As we decided to use .net to code, I found code to reuse from <a href="http://www.voiceoftech.com/swhitley/?p=681">.Net solution by Shannon Whitley</a> thanks.</p>
<p>Here are <a href="http://bit.ly/9FC9wk">pictures</a> from the event from <a href="http://twitter.com/levasha">Lev Mazin</a> from <a href="http://twitter.com/AskYourTrgtMrkt">AskYourTrgtMrkt</a> which was on hand allowing the teams to market research their ideas as they formed. </p>
<p><a href="http://twitter.com/johnsheehan">John Sheehan </a> was also there from <a href="http://www.twilio.com/">Twillio</a> they sponsored the event.  John happened to be helping out on my team and was a great asset.</p>
<p>This was my first Startup Weekend and I didn&#8217;t really know what to expect, sometimes as with this event I did little research by choice as I wanted to see how I would react to it myself.  For me it was a breath of fresh air.  Working hard for a weekend and to see the result at the end of it was a blast.  Then coming back to work on Monday feeling energized !  It brought back some good memories from startups I  had in the past.  It is really a startup mode for a weekend very much like in the real world just more compact.</p>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=912</wfw:commentRss>
		</item>
		<item>
		<title>TeamCity replacing build agent</title>
		<link>http://kristjansson.us/?p=910</link>
		<comments>http://kristjansson.us/?p=910#comments</comments>
		<pubDate>Thu, 01 Apr 2010 21:37:41 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[TeamCity]]></category>

		<category><![CDATA[build]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=910</guid>
		<description><![CDATA[We have the Professional version of TeamCity at work which allows 3 build agents / machines and 20 users.  It&#8217;s big enough for our efforts.  We just put an old build machine to bed and a new one is coming online.  However I could not find how to remove agent from the [...]]]></description>
			<content:encoded><![CDATA[<p>We have the Professional version of TeamCity at work which allows 3 build agents / machines and 20 users.  It&#8217;s big enough for our efforts.  We just put an old build machine to bed and a new one is coming online.  However I could not find how to remove agent from the TeamCity interface.  First I uninstalled the agent on the old build machine, but the profile was still on the server.  I ended up going into the Oracle TeamCity database and deleting the profile from the AGENTS table.  After that I was able to add the new build agent in the TeamCity server console.</p>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=910</wfw:commentRss>
		</item>
		<item>
		<title>Custom file extenstion in Visual Studio C#</title>
		<link>http://kristjansson.us/?p=899</link>
		<comments>http://kristjansson.us/?p=899#comments</comments>
		<pubDate>Tue, 02 Feb 2010 18:14:58 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<category><![CDATA[extension]]></category>

		<category><![CDATA[File]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=899</guid>
		<description><![CDATA[I was using some files that have among other things some C# code in it in VS.  When it dawned at me that I wasn&#8217;t getting the syntax highlighting which makes it much harder to read the code.  Visual Studio just treats it as any other text file.  In order to add [...]]]></description>
			<content:encoded><![CDATA[<p>I was using some files that have among other things some C# code in it in VS.  When it dawned at me that I wasn&#8217;t getting the syntax highlighting which makes it much harder to read the code.  Visual Studio just treats it as any other text file.  In order to add a new one you just need to set new file association within VS.  Tools - Options - Text editor - File Extensions.  Add your extension and the editor you want to use, in my case Microsoft Visual C#.  That will give you the code syntax, much better.</p>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=899</wfw:commentRss>
		</item>
		<item>
		<title>Custom Nant Task</title>
		<link>http://kristjansson.us/?p=879</link>
		<comments>http://kristjansson.us/?p=879#comments</comments>
		<pubDate>Sat, 23 Jan 2010 03:18:37 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Nant]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[build]]></category>

		<category><![CDATA[Task]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=879</guid>
		<description><![CDATA[When using Nant there is not much you can say is lacking.  Sometimes you find yourself wondering why you are cutting and pasting good amount of code between different scripts.  There has to be a better way of reusing code and sure enough there is.  Just write your own Nant extension and [...]]]></description>
			<content:encoded><![CDATA[<p>When using Nant there is not much you can say is lacking.  Sometimes you find yourself wondering why you are cutting and pasting good amount of code between different scripts.  There has to be a better way of reusing code and sure enough there is.  Just write your own Nant extension and it&#8217;s pretty simple, let&#8217;s take a look.</p>
<p>First create a class that extends the nant Task then declare the name of the task and setup the properties you want available to the user.  Lastly you will have ExecuteTask procedure that will be called by Nant when your Task executes.  That&#8217;s all the magic ! </p>
<div class="codesnip-container" >
<div class="codesnip"><span class="br0">&#91;</span>TaskName<span class="br0">&#40;</span><span class="st0">&#8220;setVersionAssembly&#8221;</span><span class="br0">&#41;</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">class</span> CxSetVersionAssembly : NAnt.<span class="me1">Core</span>.<span class="me1">Task</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>TaskAttribute<span class="br0">&#40;</span><span class="st0">&#8220;file&#8221;</span>, Required = <span class="kw1">true</span><span class="br0">&#41;</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>StringValidator<span class="br0">&#40;</span>AllowEmpty = <span class="kw1">false</span><span class="br0">&#41;</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">string</span> file<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get <span class="br0">&#123;</span> <span class="kw1">return</span> msAssemblyFile; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span class="br0">&#123;</span> msAssemblyFile = value; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>TaskAttribute<span class="br0">&#40;</span><span class="st0">&#8220;buildNumber&#8221;</span>, Required = <span class="kw1">true</span><span class="br0">&#41;</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>StringValidator<span class="br0">&#40;</span>AllowEmpty = <span class="kw1">false</span><span class="br0">&#41;</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">string</span> buildNumber<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get <span class="br0">&#123;</span> <span class="kw1">return</span> msBuildNumber; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span class="br0">&#123;</span> msBuildNumber = value; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> </p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Executes the nant task</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">protected</span> <span class="kw1">override</span> <span class="kw1">void</span> ExecuteTask<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Don&#8217;t catch errors, it will display in the build log if any</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Project.<span class="me1">Log</span><span class="br0">&#40;</span>Level.<span class="me1">Info</span>, <span class="st0">&#8220;start setVersionAssembly&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ChangeAssemblyVersionNumber<span class="br0">&#40;</span>msBuildNumber, msAssemblyFile<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>When you use it in your Nant script you will have to load your assembly first.   Once your assembly has been loaded you can start using your custom Task. </p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="re1">&lt;loadtasks</span> <span class="re0">assembly</span>=<span class="st0">&#8220;bin<span class="es0">\d</span>ebug<span class="es0">\D</span>E.Nant.Extensions.dll&#8221;</span><span class="re2">/&gt;</span></span></p>
<p>&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;setVersionAssembly</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">file</span>=<span class="st0">&#8220;${tempFile}&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">buildNumber</span>=<span class="st0">&#8220;3.333.3.3000&#8243;</span><br />
&nbsp; &nbsp; <span class="re2">/&gt;</span></span></div>
</div>
<p>This is a very brief and simple example, there are bunch of properties and other goodies you can use as you build out your custom Nant Tasks.</p>
<p>The Custom Nant Task I wrote is used to update the version of our .net assemblies during build.  Attached is the complete code including Nant script and unittests.  <a href="http://kristjansson.us/wp-content/uploads/2010/01/extension.zip">Get the code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=879</wfw:commentRss>
		</item>
		<item>
		<title>Code coverage from Nant script using Gallio and nCover</title>
		<link>http://kristjansson.us/?p=873</link>
		<comments>http://kristjansson.us/?p=873#comments</comments>
		<pubDate>Thu, 14 Jan 2010 23:02:00 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[.net]]></category>

		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[Nant]]></category>

		<category><![CDATA[TeamCity]]></category>

		<category><![CDATA[UnitTest]]></category>

		<category><![CDATA[Gallio]]></category>

		<category><![CDATA[MbUnit]]></category>

		<category><![CDATA[NCover]]></category>

		<category><![CDATA[Nunit]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=873</guid>
		<description><![CDATA[I decided to go with MbUnit for a new project, the newest version 3.x comes bundled with Gallio.  Gallio is a test runner and can run loads of different flavors of tests.  nUnit, msTest, MbUnit, etc.  Of course once you have your tests running you wonder how much of your code gets [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to go with MbUnit for a new project, the newest version 3.x comes bundled with Gallio.  Gallio is a test runner and can run loads of different flavors of tests.  nUnit, msTest, MbUnit, etc.  Of course once you have your tests running you wonder how much of your code gets coverage.  To figure that one out I added NCover, here is a sample of how you can have nCover cover your Gallio UnitTest runs. </p>
<p>For best results install Gallio on the build machine and point to that directory when you load the task<br />
loadtasks assembly=<br />
also make sure your list of assemblies to be covered is just the assembly name, not the file name.<br />
assembly.list=myAssembly1;myAssembly1;etc</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="coMULTI">&lt;!&#8211; Gallio &#8211;&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;target</span> <span class="re0">name</span>=<span class="st0">&#8220;galliounittest&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">description</span>=<span class="st0">&#8220;Runs MbUnit UnitTests using Gallio.&#8221;</span> <span class="re2">&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;*** Start Gallio unittest: &#8220;</span><span class="re2">/&gt;</span></span></p>
<p><span class="sc3"><span class="coMULTI">&lt;!&#8211; Run tests &#8211;&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;loadtasks</span> <span class="re0">assembly</span>=<span class="st0">&#8220;${path.gallio.task}Gallio.NAntTasks.dll&#8221;</span> <span class="re2">/&gt;</span></span></p>
<p><span class="sc3"><span class="re1">&lt;gallio</span><br />
&nbsp; <span class="re0">result-property</span>=<span class="st0">&#8220;exitCode&#8221;</span><br />
&nbsp; <span class="re0">failonerror</span>=<span class="st0">&#8220;false&#8221;</span><br />
&nbsp; <span class="re0">runner-type</span>=<span class="st0">&#8220;NCover&#8221;</span><br />
&nbsp; <span class="re0">report-types</span>=<span class="st0">&#8220;Html;Xml&#8221;</span><br />
&nbsp; <span class="re0">report-directory</span>=<span class="st0">&#8220;${artifacts}&#8221;</span><br />
&nbsp; <span class="re0">report-name-format</span>=<span class="st0">&#8220;gallioresults&#8221;</span><br />
&nbsp; <span class="re0">show-reports</span>=<span class="st0">&#8220;false&#8221;</span><br />
&nbsp; <span class="re0">application-base-directory</span>=<span class="st0">&#8220;${path.base.test}&#8221;</span><br />
&nbsp; <span class="re2">&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;runner</span>-property <span class="re0">value</span>=<span class="st0">&#8220;NCoverArguments=&#8217;//w ${path.base.test} //a ${assembly.list}&#8217;&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;runner</span>-property <span class="re0">value</span>=<span class="st0">&#8220;NCoverCoverageFile=&#8217;${path.ncover.dir}${coverage.xml.file}&#8217;&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="coMULTI">&lt;!&#8211; Specify the tests assemblies&nbsp; &#8211;&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;files<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;include</span> <span class="re0">name</span>=<span class="st0">&#8220;${path.base.test}${assembly.test}&#8221;</span><span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/files<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/gallio<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;fail</span> <span class="re0">if</span>=<span class="st0">&#8220;${exitCode != &#8216;0&#8242;}&#8221;</span> <span class="re2">&gt;</span></span>One or more tests failed. Please check the log for more details<span class="sc3"><span class="re1">&lt;/fail<span class="re2">&gt;</span></span></span></p>
<p><span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;*** End Gallio unittest: &#8220;</span><span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;/target<span class="re2">&gt;</span></span></span></p>
<p><span class="sc3"><span class="coMULTI">&lt;!&#8211; NCover &#8211;&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;target</span> <span class="re0">name</span>=<span class="st0">&#8220;nCoverReport&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">description</span>=<span class="st0">&#8220;Creates UnitTest Coverage report.&#8221;</span> <span class="re2">&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;*** Start nCoverReport: &#8220;</span><span class="re2">/&gt;</span></span></p>
<p>&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;ncoverexplorer</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">program</span>=<span class="st0">&#8220;${path.ncover.explorer.exe}&#8221;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">projectName</span>=<span class="st0">&#8220;${PojectName}&#8221;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">reportType</span>=<span class="st0">&#8220;ModuleClassFunctionSummary&#8221;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">outputDir</span>=<span class="st0">&#8220;${path.ncover.dir}&#8221;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">xmlReportName</span>=<span class="st0">&#8220;${coverage.xml.file}&#8221;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">htmlReportName</span>=<span class="st0">&#8220;${coverage.html.file}&#8221;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">showExcluded</span>=<span class="st0">&#8220;false&#8221;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">verbose</span>=<span class="st0">&#8220;True&#8221;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">satisfactoryCoverage</span>=<span class="st0">&#8220;1&#8243;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">failCombinedMinimum</span>=<span class="st0">&#8220;true&#8221;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">minimumCoverage</span>=<span class="st0">&#8220;0.0&#8243;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;fileset<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;include</span> <span class="re0">name</span>=<span class="st0">&#8220;${path.ncover.dir}${coverage.xml.file}&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/fileset<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;exclusions<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;exclusion</span> <span class="re0">type</span>=<span class="st0">&#8220;Assembly&#8221;</span> <span class="re0">pattern</span>=<span class="st0">&#8220;*.Tests&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;exclusion</span> <span class="re0">type</span>=<span class="st0">&#8220;Namespace&#8221;</span> <span class="re0">pattern</span>=<span class="st0">&#8220;*.Tests*&#8221;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/exclusions<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/ncoverexplorer<span class="re2">&gt;</span></span></span></p>
<p><span class="sc3"><span class="re1">&lt;echo</span> <span class="re0">message</span>=<span class="st0">&#8220;*** End nCoverReport: &#8220;</span><span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;/target<span class="re2">&gt;</span></span></span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=873</wfw:commentRss>
		</item>
		<item>
		<title>NCover error</title>
		<link>http://kristjansson.us/?p=868</link>
		<comments>http://kristjansson.us/?p=868#comments</comments>
		<pubDate>Wed, 06 Jan 2010 22:50:20 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Nant]]></category>

		<category><![CDATA[UnitTest]]></category>

		<category><![CDATA[Gallio]]></category>

		<category><![CDATA[MbUnit]]></category>

		<category><![CDATA[NCover]]></category>

		<category><![CDATA[TeamCity]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=868</guid>
		<description><![CDATA[I ran into a problem when adding NCover to our UnitTests on a new project the error I got when using NCover with Gallio was the following, Profiled process terminated. Profiler connection not established.  The FAQ that is in the NCover directory bundled with Gallio suggested - If using the command-line, did you COM [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a problem when adding NCover to our UnitTests on a new project the error I got when using NCover with Gallio was the following, <em>Profiled process terminated. Profiler connection not established</em>.  The FAQ that is in the NCover directory bundled with Gallio suggested - If using the command-line, did you COM register CoverLib.dll ?</p>
<p>Sure enough, just run<br />
>regsvr32 CoverLib.dll<br />
from a command prompt, that fixed the problem on both our build machines.</p>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=868</wfw:commentRss>
		</item>
		<item>
		<title>Nant, Tf Unable to determine the workspace</title>
		<link>http://kristjansson.us/?p=864</link>
		<comments>http://kristjansson.us/?p=864#comments</comments>
		<pubDate>Tue, 22 Dec 2009 22:21:20 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[.net]]></category>

		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Nant]]></category>

		<category><![CDATA[Repository]]></category>

		<category><![CDATA[TF]]></category>

		<category><![CDATA[TFS]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=864</guid>
		<description><![CDATA[I was using Nant to checkout files in a build script and got the error &#8220;Unable to determine the workspace&#8221; from Team Foundation Server repository.  The trick is to reset the cache first, run this command
tf workspaces /s:http://yourserver.com:8080 /noprompt
from your Nant script before doing any checkouts etc, then it should work.  
]]></description>
			<content:encoded><![CDATA[<p>I was using Nant to checkout files in a build script and got the error <em>&#8220;Unable to determine the workspace&#8221;</em> from Team Foundation Server repository.  The trick is to reset the cache first, run this command<br />
tf workspaces /s:http://yourserver.com:8080 /noprompt<br />
from your Nant script before doing any checkouts etc, then it should work.  </p>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=864</wfw:commentRss>
		</item>
		<item>
		<title>C# download web page</title>
		<link>http://kristjansson.us/?p=860</link>
		<comments>http://kristjansson.us/?p=860#comments</comments>
		<pubDate>Fri, 11 Dec 2009 00:37:05 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[.net]]></category>

		<category><![CDATA[Agile]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Networking]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[internet]]></category>

		<category><![CDATA[Download]]></category>

		<category><![CDATA[GET]]></category>

		<category><![CDATA[http]]></category>

		<category><![CDATA[URL]]></category>

		<category><![CDATA[web page]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=860</guid>
		<description><![CDATA[I&#8217;m sure you had the need sometime to download the content of a web page to be able to analyze it or work with the content.  Here is a code snippet just for you, we will use simple http GET for the specified URL.

public static string getWebPage&#40;string psUrl&#41;
&#123;
&#160; &#160; WebResponse result = null;
&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure you had the need sometime to download the content of a web page to be able to analyze it or work with the content.  Here is a code snippet just for you, we will use simple http GET for the specified URL.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">public</span> <span class="kw1">static</span> <span class="kw4">string</span> getWebPage<span class="br0">&#40;</span><span class="kw4">string</span> psUrl<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; WebResponse result = <span class="kw1">null</span>;<br />
&nbsp; &nbsp; <span class="kw4">string</span> sRet = <span class="kw4">string</span>.<span class="me1">Empty</span>;</p>
<p>&nbsp; &nbsp; <span class="kw1">try</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WebRequest req = WebRequest.<span class="me1">Create</span><span class="br0">&#40;</span>psUrl<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; req.<span class="me1">Method</span> = <span class="st0">&#8220;GET&#8221;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; req.<span class="me1">Timeout</span> = <span class="nu0">3</span> * <span class="nu0">1000</span>;&nbsp; <span class="co1">// 3 secs</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Explicit no caching, usually this is the default</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; req.<span class="me1">CachePolicy</span> = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> RequestCachePolicy<span class="br0">&#40;</span>RequestCacheLevel.<span class="me1">BypassCache</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Has to process the results if the responding service is spitting it out</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; result = req.<span class="me1">GetResponse</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Stream ReceiveStream = result.<span class="me1">GetResponseStream</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Encoding encode = <span class="kw5">System</span>.<span class="me1">Text</span>.<span class="me1">Encoding</span>.<span class="me1">GetEncoding</span><span class="br0">&#40;</span><span class="st0">&#8220;utf-8&#8243;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; StreamReader sr = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> StreamReader<span class="br0">&#40;</span>ReceiveStream, encode<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// in case the caller is interested </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sRet = sr.<span class="me1">ReadToEnd</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">finally</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>result != <span class="kw1">null</span><span class="br0">&#41;</span> result.<span class="me1">Close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; <span class="kw1">return</span> sRet;<br />
<span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=860</wfw:commentRss>
		</item>
		<item>
		<title>The solution was offline during its previous session and will remain offline</title>
		<link>http://kristjansson.us/?p=857</link>
		<comments>http://kristjansson.us/?p=857#comments</comments>
		<pubDate>Wed, 02 Dec 2009 18:33:02 +0000</pubDate>
		<dc:creator>orn</dc:creator>
		
		<category><![CDATA[.net]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[TeamFoundationServer]]></category>

		<category><![CDATA[Team Foundation Server]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://kristjansson.us/?p=857</guid>
		<description><![CDATA[If your .Net solution gets disconnected from your Team Foundation Server you might get the following message once you load your solution in Visual Studio.  &#8220;The solution was offline during its previous session and will remain offline.&#8221; in the Output window and your solution is kept offline.  Which means your local changes are [...]]]></description>
			<content:encoded><![CDATA[<p>If your .Net solution gets disconnected from your Team Foundation Server you might get the following message once you load your solution in Visual Studio.  <em>&#8220;The solution was offline during its previous session and will remain offline.&#8221;</em> in the Output window and your solution is kept offline.  Which means your local changes are not picked up automatically and you will need to do manual checkouts and checkins into the repository for local files you have changed.</p>
<p>The trick is to manually reset the values in the registry, where else ?<br />
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers\ ( Your TFS server name ) </p>
<p>set the values<br />
  AutoReconnect = 0<br />
  Offline = 0</p>
<p>Next time you open up your solution you will be asked if you want to connect to your Team Foundation Server,  yes please.</p>
<p>Update&#8230;<br />
If that does not work, try <a href="http://i-m-code.com/blog/post/2009/12/29/Solution-Stuck-Offline-from-TFS.aspx">this one</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kristjansson.us/?feed=rss2&amp;p=857</wfw:commentRss>
		</item>
	</channel>
</rss>
