Monday 28 January 2013

A Return to Unit Testing using xcodebuild

I have previously written a couple of posts on the testing of iOS applications by executing command line only commands. What I did:

xcodebuild -sdk iphonesimulator -project JonsProject.xcodeproj -target JonsProjectTest -configuration Debug TEST_AFTER_BUILD=YES

This used to fire up the simulator and execute the test schema. Now I get this:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/Tools/RunPlatformUnitTests:81: warning: Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set).

Partly I think that I might have lost my mind as the tests worked, I saw them work, they worked!  However, the build server on which all of this worked now does not, but then the scripts for the CI

have changed. So, which stopped working first? Who knows, but it's not adding to my positive mental health.

Anyway at least one of my colleagues has been suggesting that we use this run the simulator and execute the tests:

https://github.com/sgleadow/xcodetest

I am not sure that this is a wonderful idea as it appears to involve compiled in binaries. Which I don't think I agree with. You shouldn't have to alter your code to use what is a base "feature" of the IDE.

After a bit of poking around the script that gets executed there are these blocks of code:

RunTestsForApplication() {
    Warning ${LINENO} "Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set)."
}



and 

if [ "${TEST_HOST}" != "" ]; then
    # All applications are tested the same way, by injecting a bundle.
    # The bundle needs to configure and run the tests itself somehow.

    RunTestsForApplication "${TEST_HOST}" "${TEST_BUNDLE_PATH}"

else
    # If no TEST_HOST is specified, assume we're running the test bundle.
   
    RunTestsForBundle "${TEST_BUNDLE_PATH}"
fi



Which kind of implies that RunTestsForApplication will be supported in the future and is somehow related to the setting of the TEST_HOST environment variable.  But what happens if you set that variable to blank?  Well, given this command:

xcodebuild -sdk iphonesimulator -project JonsProject.xcodeproj -target JonsProjectTests -configuration Debug  TEST_AFTER_BUILD=YES TEST_HOST=""

The unit tests run.  And fail, correctly, in my case.

error: -[JonsProjectTests testExample] : Unit tests are not implemented yet in Jons Password KeeperTests
Test Case '-[JonsProjectTests testExample]' failed (0.000 seconds).

Test Suite 'JonsProjectTests' finished at 2013-01-28 10:25:32 +0000.
Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.000) seconds

Test Suite '/build/Debug-iphonesimulator/JonsProjectTests.octest(Tests)' finished at 2013-01-28 10:25:32 +0000.
Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.001) seconds


But, but, but the simulator isn't open.  I remember, distinctly, that to get this lot working in the past, the simulator HAD to be open.

I am so losing my mind.


24 comments:

  1. Try https://github.com/facebook/xctool

    ReplyDelete
  2. Try this:

    xcodebuild test -scheme JonsProject -configuration Debug -sdk iphonesimulator7.0 -destination OS=7.0,name="iPhone Retina (4-inch)"

    ReplyDelete
  3. Hi,

    Thanks for sharing a very interesting article about A Return to Unit Testing using xcodebuild. This is very useful information for online blog review readers. Keep it up such a nice posting like this.

    From,
    Maestro Infotech,
    Web Design Company Bangalore

    ReplyDelete
  4. This article gives the light in which we can observe the reality. this is very nice one and gives in-depth information. Thanks for this nice article
    Web design company in chennai
    Web development company in chennai
    Mobile app development company in chennai

    ReplyDelete
  5. Hello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. londonstonemasonry

    ReplyDelete
  6. Roofing contractors in Calgary can be found on almost any corner these days. Since your home is likely the most expensive investment you’ve made and own, and you want to take care of it. So, when you need repairs or replacement for your roof, you should use the best service you can find. In Calgary, roofing needs should be serviced by a professional that has experience and recent references you can check.

    ReplyDelete
  7. Site Galleria is a Web development company in Bangalore. It provides other services such as Mobile App Development Services for consumer-facing and corporate environments. We also provide Ecommerce web development services, Digital Marketing and SEO Services. We have a team of experienced SEO professionals who will understand your business and create a strategy to fulfil your commercial objectives. Site Galleria is also recognized as best Digital Marketing company in Bangalore.

    Site Galleria has launched its product called Examin, an online exam software to conduct online examinations, EduInPro - Professional certification training platform, LiveChatSupport - A complete help desk software having FAQ Software, Ticket Management Software, Live Chat box and more.

    Site Galleria also provides Ecommerce web development services across the world. has been delivering custom designed websites, mobile application and is still the leading Website Designing Company in Bangalore. Site Galleria combines technical expertise, proven methodologies, and business domain knowledge of 150+ skilled professionals to deliver high-quality solutions to maintain its reputation as the best Web Development Company in India.

    Services Offered by Site Galleria:
    Web Designing and Development
    iOS App Development
    Android App Development
    SEO Services
    Digital Marketing Services
    PHP Website Development
    Web Hosting and Domain Registration
    CMS and E-commerce Website Development
    Affiliate Marketing Service

    Site Galleria Contact Details:
    #7, 2nd Main, 3rd Phase, JP NAGAR,
    Bangalore-560078
    Email: info@sitegalleria.com
    Phone: 8095942111
    Website: www.sitegalleria.com

    ReplyDelete
  8. Site Galleria is a Web development company in Bangalore It provides other services such as Mobile App Development Services for consumer-facing and corporate environments. We also provide Ecommerce web development services, Digital Marketing and SEO Services We have a team of experienced SEO professionals who will understand your business and create a strategy to fulfil your commercial objectives. Site Galleria is also recognized as best Digital Marketing company in Bangalore

    ReplyDelete
  9. Nice Blog. This is information is very helpful. We provides services Mobile Application Development Company in Bangalore

    ReplyDelete
  10. Hi, I Read your blog and I feel it is a very wonderful, informative blog .
    There are a lot of good information on this blog, I'd like to Share and I think people will get a lot of support from this blog.
    Thank you for sharing this informative blog, please keep up and share some unique posts with us in the future
    Software testing company in India
    ARVR Development Company in India
    Technical Support Company in India

    ReplyDelete
  11. Very interesting, good job and thanks for sharing such a good blog. your article is so convincing that I never stop myself to say something about it. You’re doing a great job. Keep it up virtual reality development services in India

    ReplyDelete
  12. I appreciate your time invested on this article , too bad it took me this long to find it but as they simply sound out a good is hard to find. Keep it up.
    Check out the top Android app developer in bangalore|
    |Android App Development Company Bangalore|
    |UX Design Companies In Bangalore|
    |Android app development company in bangalore
    |UI UX Design Companies In Bangalore |

    ReplyDelete
  13. Nice post really useful information. We are the leading website development services in dubai. Hire our web design agency in dubai today for web design services in dubai

    ReplyDelete
  14. Nice post it is really an interesting article.We are also providing the web design services in mumbai. We are the leading
    web design companies in mumbai
    website designers in mumbai

    ReplyDelete
  15. Thanks for your great post.We are the leading seo company in mumbai. Hire our seo agency in mumbai today for seo services in mumbai

    ReplyDelete
  16. Nice post really useful information. We are the leading Ecommerce Website Designers in Bangalore . Hire our ecommerce website designers in bangalore for ecommerce website development services.

    ReplyDelete
  17. Thank you for discussing this very useful article.We are the leading android app development company in bangalore. Hire our web development company in bangalore today

    ReplyDelete
  18. We are helping eCommerce businesses by increasing their customer reach and growing revenue through the optimal combination tools, and user-centric solutions. Being India’s leading eCommerce software development company, we help B2B & B2C clients drive their customers’ satisfaction, expand their right potential audiences and boost sales upto 100%.
    Ecommerce development Company

    ReplyDelete
  19. Amazing article. It's very useful.
    It looks like you have put lot of work into this.
    SMARS designs jewelry to run along with your ever-changing wardrobe. A piece of Jewelry can either make or break your entire look; therefore, every unique outfit needs a different piece of jewelry to compliment it. But looking at the prices of traditional jewelry, we usually find occasions like festivals or ceremonies to buy it. And these adorable pieces spend most of their lives in the lockers. Komal, the founder of SMARS, understood this gap in the market. Every single piece is limited edition and walks hand-in-hand with trends. Adored by customers from all over the world, we ensure the quality delivery of our high-end, Indian fashion costume jewelry. Shop online for latest collection of Kundan, antique and temple jewelry in India check out necklace sets, earrings, bangles, chokers for girls and many more Indian jewelry sets for women available with free shipping across India.
    Take a look: Buy Traditional Bangles Set For Womens

    ReplyDelete
  20. really nice required information.just recommended you the best digital marketing services in Surat

    ReplyDelete