tags:

views:

200

answers:

2

Hi,

I have added a new job in my hudson server which builds the project with a makefile.

Execute shell command:

#!/bin/bash
cd $JOB_NAME
make

My makefile looks like this

SDK_31 = iphonesimulator3.1
TARGET_DEV = myProject
TARGET_TEST = unitTest

all: debug
debug:
        xcodebuild -sdk ${SDK_31} -target "${TARGET_DEV}" -configuration Debug
        xcodebuild -sdk ${SDK_31} -target "${TARGET_TEST}" -configuration Debug

clean:
        xcodebuild -alltargets clean
        rm -rf build

But when hudson build the projects, some unit tests fail but the build is tagged as successful.

What should I have to do to have an "unstable project" ?

Best regards,

+1  A: 
Robert Munteanu
Thanks for your answer.As it is not a java project, I do not use JUnit for my unit test, so a do not have TEst report XMLs. But maybe I need a plugin to use my unit test result in hudson build state. I'll check this.Regards,
Quentin
How does your build signal failure then?
Robert Munteanu
Actually the build result in console looks like:--------------------Test Suite '/Users/user/Documents/workspace/iPhone/sandbox/app/build/Debug-iphonesimulator/unitTest.app' finished at 2009-09-17 13:44:44 +0200.Executed 4 tests, with 1 failures (1 unexpected) in 1.055 (1.055) seconds...** BUILD SUCCEEDED **--------------------------It seems that I should use plugins like Hudson Text-finder plugin and Warnings plugin to get this unit test failures.Regards
Quentin
Right, I added the text finder plugin. Does xcode save the test results in a file of some sort?
Robert Munteanu
I configured text finder plugin to parse console output and it works.
Quentin
A: 

I found this handy ruby script by Christian Hedin that converts the output of OCUnit tests (the format used by Xcode) into JUnit xml files (the format used by Hudson).

You can grab the script on github: http://github.com/ciryon/OCUnit2JUnit

and for an explanation of how to use it, here's his blog post about it: http://blog.jayway.com/2010/01/31/continuos-integration-for-xcode-projects/

Basically, you pipe xcodebuild into ocunit2junit.rb with a command like this:

/usr/bin/xcodebuild -target UnitTests | /usr/local/bin/ocunit2junit.rb

and it places the xml files into a test-reports folder that it creates at the root of your project folder. Then tell Hudson to copy the test-reports/*.xml artifacts as the JUnit results and you're set.

This setup will allow Hudson to correctly identify if a unit test has passed or failed and correctly mark the stability of the build.

I've been using it for a month now and it works great. The setup was very simple.

Mark Suman