@@ -25,6 +25,9 @@ OUTPUT_DIR=/tmp/xcodetest/${MAIN_APP_TARGET}
25
25
XCODE_TEST_PATH=${OUTPUT_DIR} /${UNIT_TEST_TARGET} .octest/${UNIT_TEST_TARGET}
26
26
XCODE_TEST_LDFLAGS=" -all_load -ObjC -framework SenTestingKit${LINK_TO_XCODE_TEST_LIB} -F\" $\(SDKROOT\)/Developer/Library/Frameworks\" "
27
27
28
+ # More reliable if the simulator is not already running
29
+ osascript -e' tell app "iPhone Simulator" to quit'
30
+
28
31
# Build the unit tests bundle, so it can be fed into waxsim
29
32
xcodebuild -sdk iphonesimulator -scheme${UNIT_TEST_TARGET} build CONFIGURATION_BUILD_DIR=" ${OUTPUT_DIR} "
30
33
if [[$? != 0 ]]; then
43
46
which waxsim
44
47
if [[$? != 0 ]]; then
45
48
echo " Could not find 'waxsim', make sure it is installed and try again"
46
- exit 1
49
+ exit $?
47
50
fi
48
51
52
+ # Warn users that it wont run the tests unless you tweak the linker settings
53
+ echo " ================="
54
+ echo " If tests do not run, make sure you have included XCODE_TEST_LDFLAGS in your linker flags:"
55
+ echo " In xcconfigs: OTHER_LDFLAGS =\$ (inherited)\$ (XCODE_TEST_LDFLAGS)"
56
+ echo " In Xcode: set Other Linker Flags to include\$ (XCODE_TEST_LDFLAGS)"
57
+ echo " ================="
58
+
49
59
# Run the app in the simulator, will automatically load and run unit tests
50
60
OUT_FILE=${OUTPUT_DIR} /waxsim.out
51
- waxsim${OUTPUT_DIR} /${MAIN_APP_TARGET} .app -SenTest All -e XCODE_TEST_PATH=${XCODE_TEST_PATH} > ${OUT_FILE} 2>&1
61
+ XCODE_TEST_PATH=${XCODE_TEST_PATH} waxsim${OUTPUT_DIR} /${MAIN_APP_TARGET} .app -SenTest All> ${OUT_FILE} 2>&1
62
+ cat${OUT_FILE}
63
+ osascript -e' tell app "iPhone Simulator" to quit'
52
64
53
65
# if there was a failure, show what waxsim was hiding and crucially return with a non-zero exit code
54
66
grep -q" : error:" $OUT_FILE
55
67
success=` exec grep -c" : error:" $OUT_FILE `
56
68
57
69
if [[$success != 0 ]]; then
58
- cat$OUT_FILE
59
- echo " ==========================================="
60
- echo " GUI Tests failed"
61
- echo " ==========================================="
70
+ echo " ================="
71
+ echo " Unit Tests Failed"
72
+ echo " ================="
62
73
exit 1
63
74
else
64
- grep -v" started" $OUT_FILE | grep" Test Case"
65
- echo " ==========================================="
66
- echo " GUI Tests passed"
67
- echo " ==========================================="
75
+ echo " ================="
76
+ echo " Unit Tests Passed"
77
+ echo " ================="
68
78
fi