Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
Enable unit-tests for iOS project
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantvc committed Jan 19, 2018
1 parent 4c30004 commit 695b2a1
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 109 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ x86/
bld/
[Bb]in/
[Oo]bj/
unit-test-tools

# Visual Studio 2015 cache/options directory
.vs/
Expand Down
6 changes: 4 additions & 2 deletions tests/Connectivity.Tests.iOS/Connectivity.Tests.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchArch>i386</MtouchArch>
<MtouchArch>i386, x86_64</MtouchArch>
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchExtraArgs>-setenv=NUNIT_ENABLE_XML_OUTPUT=true --setenv=NUNIT_SKIP_LOG_HEADER=true</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
Expand All @@ -32,9 +33,10 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MtouchLink>None</MtouchLink>
<MtouchArch>i386</MtouchArch>
<MtouchArch>i386, x86_64</MtouchArch>
<ConsolePause>false</ConsolePause>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchExtraArgs>-setenv=NUNIT_ENABLE_XML_OUTPUT=true --setenv=NUNIT_SKIP_LOG_HEADER=true</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion tests/Connectivity.Tests.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string></string>
<string>10.2</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
Expand Down
47 changes: 47 additions & 0 deletions tests/Connectivity.Tests.iOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
TOUCH_SERVER=unit-test-tools/Touch.Server.exe
TEST_RESULT=./test_results.xml
MTOUCH=/Developer/MonoTouch/usr/bin/mtouch
UNIT_SUMMARY=unit-test-tools/nunit-summary.exe
THIS_FILE := $(lastword $(MAKEFILE_LIST))
PROJECT_FILE=Connectivity.Tests.iOS.csproj
APP_NAME=ConnectivityTestsiOS.app

all: build-simulator build-device

run-all-tests: run-simulator run-device

build-simulator:
msbuild $(PROJECT_FILE) /t:Rebuild

build-device:
msbuild $(PROJECT_FILE) /t:ReBuild /p:Platform=iPhone

run-simulator-tests: download-server build-simulator
mono --debug $(TOUCH_SERVER) \
--launchsim ./bin/iPhoneSimulator/Debug/$(APP_NAME) \
-autoexit -skipheader \
-logfile=$(TEST_RESULT) \
--verbose \
--device=":v2:runtime=com.apple.CoreSimulator.SimRuntime.iOS-11-2,devicetype=com.apple.CoreSimulator.SimDeviceType.iPhone-SE"
@$(MAKE) -f $(THIS_FILE) show-results

run-device-tests: download-server build-device
$(MTOUCH) --installdev ./bin/iPhone/Debug/$(APP_NAME)
mono --debug $(TOUCH_SERVER) --launchdev com.plugin.connectivity -autoexit -skipheader -logfile=$(TEST_RESULT)
@$(MAKE) -f $(THIS_FILE) show-results

show-results:
mono $(UNIT_SUMMARY) $(TEST_RESULT)
rm -rf $(TEST_RESULT)

download-server:
@if ! test -f $(TOUCH_SERVER); then \
curl -L -O "https://github.com/prashantvc/Touch.Server/releases/download/0.1/Touch.Server.exe" > Touch.Server.exe; \
mkdir unit-test-tools; \
mv Touch.Server.exe $(TOUCH_SERVER); \
fi

@if ! test -f $(UNIT_SUMMARY); then \
curl -L -O "https://github.com/prashantvc/nunit-summary/releases/download/0.4/nunit-summary.exe" > nunit-summary.exe; \
mv nunit-summary.exe $(UNIT_SUMMARY); \
fi
26 changes: 26 additions & 0 deletions tests/Connectivity.Tests.iOS/run-unittests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

echo 'Output path = ' $1

TEST_RESULT=$1/test_results.xml
TOUCH_SERVER=unit-test-tools/Touch.Server.exe


echo 'Delete test result'
rm -rf $TEST_RESULT

#downloading touch.server
if [ ! -f $TOUCH_SERVER ]; then
echo "Touch server doesn't exists"
curl -L -O "https://github.com/prashantvc/Touch.Server/releases/download/0.1/Touch.Server.exe" > Touch.Server.exe
mkdir unit-test-tools
mv Touch.Server.exe $TOUCH_SERVER
fi;

mono --debug $TOUCH_SERVER \
--launchsim ./bin/iPhoneSimulator/Debug/ConnectivityTestsiOS.app \
-autoexit \
-skipheader \
-logfile=$TEST_RESULT \
--verbose \
--device=":v2:runtime=com.apple.CoreSimulator.SimRuntime.iOS-11-2,devicetype=com.apple.CoreSimulator.SimDeviceType.iPhone-SE"
Loading

0 comments on commit 695b2a1

Please sign in to comment.