forked from XCTestHTMLReport/XCTestHTMLReport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepareTestResults.sh
executable file
·63 lines (52 loc) · 2.16 KB
/
prepareTestResults.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -ex
cd XCTestHTMLReportSampleApp
SIM_DESTINATION="platform=iOS Simulator,name=iPhone 12,OS=latest"
set +e
xcrun simctl list devices --json | grep '"name" : "iPhone 12"' 2> /dev/null
if [[ $? -ne 0 ]]; then
xcrun simctl create "iPhone 12" "iPhone 12"
fi
set -e
# Create TestResults.xcresult for functional tests
FILENAME='TestResults.xcresult'
rm -rf "$FILENAME"
xcodebuild test \
-project SampleApp.xcodeproj \
-scheme MainScheme \
-destination "$SIM_DESTINATION" \
-skip-testing:SampleAppUITests/RetryTests \
-resultBundlePath "$FILENAME" || true
echo "Even if some test failed this is OK."
echo "${FILENAME} should contain succeed, failed and skipped tests for xchtmlreport functional testing"
mkdir -p "../Tests/XCTestHTMLReportTests/Resources/"
rm -rf "../Tests/XCTestHTMLReportTests/Resources/${FILENAME}"
mv "$FILENAME" "../Tests/XCTestHTMLReportTests/Resources/"
SANITY_FILENAME='SanityResults.xcresult'
rm -rf "$SANITY_FILENAME"
xcodebuild test \
-project SampleApp.xcodeproj \
-scheme MainScheme \
-destination "$SIM_DESTINATION" \
-only-testing:SampleAppUITests/FirstSuite/testOne \
-resultBundlePath "$SANITY_FILENAME" || true
echo "${SANITY_FILENAME} should contain sample data for sanity tests"
rm -rf "../Tests/XCTestHTMLReportTests/Resources/${SANITY_FILENAME}"
mv "$SANITY_FILENAME" "../Tests/XCTestHTMLReportTests/Resources/"
if [[ $XCODE_VERSION != 12.* && $XCODE_VERSION != 11.* ]]; then
# "Mixed" test results must be run separately to use -retry-tests-on-failure
RETRY_FILENAME='RetryResults.xcresult'
rm -rf "$RETRY_FILENAME"
xcodebuild test \
-project SampleApp.xcodeproj \
-scheme MainScheme \
-destination "$SIM_DESTINATION" \
-test-iterations 2 \
-retry-tests-on-failure \
-only-testing:SampleAppUITests/RetryTests \
-resultBundlePath "$RETRY_FILENAME" || true
echo "${RETRY_FILENAME} will contain mixed test results"
rm -rf "../Tests/XCTestHTMLReportTests/Resources/${RETRY_FILENAME}"
mv "$RETRY_FILENAME" "../Tests/XCTestHTMLReportTests/Resources/"
fi
echo "$(tput setaf 2)$(basename "$0") successfully finished$(tput sgr 0)"