title: Implementing Unit Testing with iOS
body: <p>I've followed <a href="http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html#//apple_ref/doc/uid/TP40007959-CH20-SW3" rel="nofollow noreferrer">this tutorial</a> to setup unit testing on my app when I got a little stuck. </p>
  
  <p>At bullet point 8 in that tutorial it shows this image, which is what I should be expecting when I build: <a href="http://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iphone_development/art/logic_test_failure_text_editor.jpg" rel="nofollow noreferrer">alt text http://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iphone_development/art/logic_test_failure_text_editor.jpg</a></p>
  
  <p>However this isn't what I get when I build. I get this error message: <code>Command /bin/sh failed with exit code 1</code> as well as the error message the unit test has created. Then, when I expand on the first error I get this:</p>
  
  <pre><code>PhaseScriptExecution "Run Script" "build/3D Pool.build/Debug-iphonesimulator/LogicTests.build/Script-1A6BA6AE10F28F40008AC2A8.sh"
  cd "/Users/james/Desktop/FYP/3D Pool"
  setenv ACTION build
  setenv ALTERNATE_GROUP staff
  ...
  setenv XCODE_VERSION_MAJOR 0300
  setenv XCODE_VERSION_MINOR 0320
  setenv YACC /Developer/usr/bin/yacc
  /bin/sh -c "\"/Users/james/Desktop/FYP/3D Pool/build/3D Pool.build/Debug-iphonesimulator/LogicTests.build/Script-1A6BA6AE10F28F40008AC2A8.sh\""
  
  /Developer/Tools/RunPlatformUnitTests.include:412: note: Started tests for architectures 'i386'
  /Developer/Tools/RunPlatformUnitTests.include:419: note: Running tests for architecture 'i386' (GC OFF)
  objc[12589]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
  Test Suite '/Users/james/Desktop/FYP/3D Pool/build/Debug-iphonesimulator/LogicTests.octest(Tests)' started at 2010-01-04 21:05:06 +0000
  Test Suite 'LogicTests' started at 2010-01-04 21:05:06 +0000
  Test Case '-[LogicTests testFail]' started.
  /Users/james/Desktop/FYP/3D Pool/LogicTests.m:17: error: -[LogicTests testFail] : Must fail to succeed.
  Test Case '-[LogicTests testFail]' failed (0.000 seconds).
  Test Suite 'LogicTests' finished at 2010-01-04 21:05:06 +0000.
  Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.000) seconds
  
  Test Suite '/Users/james/Desktop/FYP/3D Pool/build/Debug-iphonesimulator/LogicTests.octest(Tests)' finished at 2010-01-04 21:05:06 +0000.
  Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.002) seconds
  
  /Developer/Tools/RunPlatformUnitTests.include:448: error: Failed tests for architecture 'i386' (GC OFF)
  /Developer/Tools/RunPlatformUnitTests.include:462: note: Completed tests for architectures 'i386'
  Command /bin/sh failed with exit code 1
  </code></pre>
  
  <p>Now this is very odd as it is running the tests (and succeeding as you can see my STFail firing) because if I add a different test which passes I get no errors, so the tests are working fine. But why am I getting this extra build fail?</p>
  
  <p>It may also be of note that when downloading solutions/templates which should work out the box, I get the same error. I'm guessing I've set something up wrong here but I've just followed a tutorial 100% correctly!</p>
  
  <p>EDIT: According to <a href="http://www.mcubedsw.com/blog/index.php/site/comments/xcode_3.2_teh_awesome_edition/" rel="nofollow noreferrer">this blog</a>, <a href="http://osdir.com/ml/xcode-users/2009-10/msg00216.html" rel="nofollow noreferrer">this post</a> and a few other websites, I'm not the only one getting this problem. It has been like this since the release of xCode 3.2, assuming the apple dev center documents and tutorials etc are pre-3.2 as well.</p>
  
  <p>However some say its a known issue whereas others seem to think this was intentional. I for one would like both the extended console and in code messages, and I certainly do not like the "Command /bin/sh..." error and really think they would have documented such an update. Hopefully it will be fixed soon anyway.</p>
  
  <p>UPDATE:
  Here's confirmation it's something changed since the release of xCode 3.2.1.</p>
  
  <p>This image:
  <a href="http://ing0.co.uk/info/pics/unittest-xcode-3.2.1.png" rel="nofollow noreferrer">alt text http://ing0.co.uk/info/pics/unittest-xcode-3.2.1.png</a> is from my test build using 3.2.1. This one is from an older version (3.1.4):
  <a href="http://ing0.co.uk/info/pics/unittest-xcode-3.1.4.png" rel="nofollow noreferrer">alt text http://ing0.co.uk/info/pics/unittest-xcode-3.1.4.png</a>. (The project for both was unchanged).</p>