<?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>Thinking Cocoa</title>
	<atom:link href="http://bazyl.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://bazyl.net</link>
	<description>Developing iOS and Mac OS X Apps</description>
	<lastBuildDate>Tue, 10 Jan 2012 14:04:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Unit test results</title>
		<link>http://bazyl.net/2012/01/unit-test-results/</link>
		<comments>http://bazyl.net/2012/01/unit-test-results/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 14:04:19 +0000</pubDate>
		<dc:creator>bazyl</dc:creator>
				<category><![CDATA[Developer Tools]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[unit]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://bazyl.net/?p=3373</guid>
		<description><![CDATA[Sometimes (according to Google &#8211; never ) one have a need to gather all results from unit tests. In example &#8211; to send them through the network. Why? Imagine that you need to report every unit test results to corporate server. Just to check for regressions&#8230; or something. I need it so my students can check &#8220;The Board&#8221; during the challenge. Unluckily OCUnit given in XCode4 doesn&#8217;t seem to allow us to gather this kind of information. There is a solution though. SenTestCase doesn&#8217;t have any methods that can return the results. What&#8217;s more &#8211; it is created and prepared for each test separately. That&#8217;s unfortunate. The entry method that is called for each test is -(void)performTest:(SenTestRun *)aRun; That give&#8217;s us a hint when the test is actually triggered. But we still don&#8217;t know which one and how many of them are still left. But we can count the number of runs&#8230; information about the number of test methods in the class we can get from Class itself. So we simply add following method to our test case: - &#40;void&#41;performTest:&#40;SenTestRun *&#41; aRun &#123; static int performed = 0; static int failed = 0; static int totalTestCount = 0; &#160; if &#40;totalTestCount == 0&#41; &#123; totalTestCount = &#91;&#91;&#91;self class&#93; testInvocations&#93; count&#93;; &#125; &#160; &#91;super performTest:aRun&#93;; performed++; if &#40;&#91;aRun failureCount&#93;&#41; failed++; &#160; if &#40;performed == totalTestCount&#41; &#123; NSLog&#40;@&#34;Total tests %u failed %u&#34;, performed, failed&#41;; &#125; &#125;]]></description>
			<content:encoded><![CDATA[<p>Sometimes (according to Google &#8211; never <img src='http://bazyl.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ) one have a need to gather all results from unit tests. In example &#8211; to send them through the network. Why? Imagine that you need to report every unit test results to corporate server. Just to check for regressions&#8230; or something. I need it so my students can check &#8220;The Board&#8221; during the challenge.</p>
<p>Unluckily OCUnit given in XCode4 doesn&#8217;t seem to allow us to gather this kind of information. There is a solution though.</p>
<p><strong><span style="color: #000080;">SenTestCase</span></strong><span style="color: #000000;"> doesn&#8217;t have any methods that can return the results. What&#8217;s more &#8211; it is created and prepared for each test separately. That&#8217;s unfortunate.</span></p>
<p>The entry method that is called for each test is -(void)performTest:(<span style="color: #000080;">SenTestRun</span> *)aRun; That give&#8217;s us a hint when the test is actually triggered. But we still don&#8217;t know which one and how many of them are still left. But we can count the number of runs&#8230; information about the number of test methods in the class we can get from <span style="color: #000080;">Class</span> itself.</p>
<p>So we simply add following method to our test case:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>performTest<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>SenTestRun <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> aRun
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">static</span> <span style="color: #a61390;">int</span> performed <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
    <span style="color: #a61390;">static</span> <span style="color: #a61390;">int</span> failed <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
    <span style="color: #a61390;">static</span> <span style="color: #a61390;">int</span> totalTestCount <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>totalTestCount <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        totalTestCount <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self class<span style="color: #002200;">&#93;</span> testInvocations<span style="color: #002200;">&#93;</span> count<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #002200;">&#91;</span>super performTest<span style="color: #002200;">:</span>aRun<span style="color: #002200;">&#93;</span>;
    performed<span style="color: #002200;">++</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>aRun failureCount<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
        failed<span style="color: #002200;">++</span>;
&nbsp;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>performed <span style="color: #002200;">==</span> totalTestCount<span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Total tests %u failed %u&quot;</span>, performed, failed<span style="color: #002200;">&#41;</span>;
    <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bazyl.net/2012/01/unit-test-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About time!</title>
		<link>http://bazyl.net/2011/12/about-time/</link>
		<comments>http://bazyl.net/2011/12/about-time/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 02:17:12 +0000</pubDate>
		<dc:creator>bazyl</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://bazyl.net/?p=3370</guid>
		<description><![CDATA[It took me a while to make this decission. I&#8217;m working with Cocoa for years. And I&#8217;ve started working on iOS from the day one &#8211; day when iPhone OS SDK beta was release for the first time. I was in my own developer heaven. I&#8217;ve connected my previous knowledge from embedded systems development with my knowledge (and yes &#8211; enthusiasm!) from Mac OS X. It worked! Years passed and I&#8217;ve figured out that in most companies I&#8217;ve worked for I am the only iOS developer on site! I understood that most of developers I worked with have a lot of trouble understanding how Cocoa Touch works and why it&#8217;s different. I&#8217;ve started training courses, teaching people how to develop for iOS. But trainings are always very intense. And sometimes I just want to share with something with my students. Or work collegues. Thus &#8211; this page. I&#8217;ll try to update it as often as I can giving you some hints how I solve everyday problems in Mac OS X and iOS development.]]></description>
			<content:encoded><![CDATA[<p>It took me a while to make this decission. I&#8217;m working with Cocoa for years. And I&#8217;ve started working on iOS from the day one &#8211; day when iPhone OS SDK beta was release for the first time.</p>
<p>I was in my own developer heaven. I&#8217;ve connected my previous knowledge from embedded systems development with my knowledge (and yes &#8211; enthusiasm!) from Mac OS X. It worked!</p>
<p>Years passed and I&#8217;ve figured out that in most companies I&#8217;ve worked for I am the only iOS developer on site!</p>
<p>I understood that most of developers I worked with have a lot of trouble understanding how Cocoa Touch works and why it&#8217;s different.</p>
<p>I&#8217;ve started training courses, teaching people how to develop for iOS. But trainings are always very intense. And sometimes I just want to share with something with my students. Or work collegues. Thus &#8211; this page.</p>
<p>I&#8217;ll try to update it as often as I can giving you some hints how I solve everyday problems in Mac OS X and iOS development.</p>
]]></content:encoded>
			<wfw:commentRss>http://bazyl.net/2011/12/about-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

