Skip to content

Commit

Permalink
Xcode: project + script for running XCUITests against arbitrary .app
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoody committed Jan 9, 2018
1 parent 48ce176 commit 6cb21d8
Show file tree
Hide file tree
Showing 11 changed files with 575 additions and 8 deletions.
135 changes: 135 additions & 0 deletions DeviceAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@
F5CE18E41E8BBA61001116A5 /* CBLSApplicationProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = F5CE18E11E8BBA61001116A5 /* CBLSApplicationProxy.m */; };
F5D086A41F38C96B008B894C /* RevealServer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5D086A31F38C96B008B894C /* RevealServer.framework */; };
F5D42A191D40E3150041105C /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5D42A181D40E3150041105C /* AVFoundation.framework */; };
F5DD368E20036D7200308564 /* StandAloneUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F5DD368D20036D7200308564 /* StandAloneUITests.m */; };
F5DED03F1D7634AB00563648 /* SpringBoardAlert.h in Headers */ = {isa = PBXBuildFile; fileRef = F5DED03D1D7634AB00563648 /* SpringBoardAlert.h */; };
F5DED0401D7634AB00563648 /* SpringBoardAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = F5DED03E1D7634AB00563648 /* SpringBoardAlert.m */; };
F5DED0411D7634AB00563648 /* SpringBoardAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = F5DED03E1D7634AB00563648 /* SpringBoardAlert.m */; };
Expand Down Expand Up @@ -622,6 +623,13 @@
remoteGlobalIDString = 898743BB1C5847B30084FD93;
remoteInfo = CBXAppStub;
};
F5DD369020036D7200308564 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 898743B41C5847B30084FD93 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 898743BB1C5847B30084FD93;
remoteInfo = AppStub;
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -1149,6 +1157,9 @@
F5CE18E11E8BBA61001116A5 /* CBLSApplicationProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CBLSApplicationProxy.m; sourceTree = "<group>"; };
F5D086A31F38C96B008B894C /* RevealServer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RevealServer.framework; path = Vendor/RevealServer.framework; sourceTree = "<group>"; };
F5D42A181D40E3150041105C /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
F5DD368B20036D7200308564 /* StandAloneUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = StandAloneUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
F5DD368D20036D7200308564 /* StandAloneUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StandAloneUITests.m; sourceTree = "<group>"; };
F5DD368F20036D7200308564 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F5DED03D1D7634AB00563648 /* SpringBoardAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpringBoardAlert.h; sourceTree = "<group>"; };
F5DED03E1D7634AB00563648 /* SpringBoardAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SpringBoardAlert.m; sourceTree = "<group>"; };
F5DED0421D76368000563648 /* SpringBoardAlertTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SpringBoardAlertTest.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1238,6 +1249,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
F5DD368820036D7200308564 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand All @@ -1252,6 +1270,7 @@
F55F7FEA1C6DD07500A945C8 /* Vendor */,
F5169D0E1CFE06B700252F52 /* Licenses */,
F50BB27C1D73392100264915 /* Permissions */,
F5DD368C20036D7200308564 /* StandAloneUITests */,
F542EA1A1CC53DD000D87200 /* Frameworks */,
898743BD1C5847B30084FD93 /* Products */,
);
Expand All @@ -1270,6 +1289,7 @@
F58D28181D4F964D000FF6C0 /* UITest.xctest */,
F50BB27B1D73392100264915 /* Permissions.app */,
F50BB2931D73392200264915 /* Dismiss.xctest */,
F5DD368B20036D7200308564 /* StandAloneUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -2274,6 +2294,15 @@
path = Pan;
sourceTree = "<group>";
};
F5DD368C20036D7200308564 /* StandAloneUITests */ = {
isa = PBXGroup;
children = (
F5DD368D20036D7200308564 /* StandAloneUITests.m */,
F5DD368F20036D7200308564 /* Info.plist */,
);
path = StandAloneUITests;
sourceTree = "<group>";
};
F5E1D8871DEC8E8400B72A8E /* Misc */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2655,6 +2684,24 @@
productReference = F5B0A0CF1CAD3CBC00E056CE /* UnitTest.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
F5DD368A20036D7200308564 /* StandAloneUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = F5DD369420036D7200308564 /* Build configuration list for PBXNativeTarget "StandAloneUITests" */;
buildPhases = (
F5DD368720036D7200308564 /* Sources */,
F5DD368820036D7200308564 /* Frameworks */,
F5DD368920036D7200308564 /* Resources */,
);
buildRules = (
);
dependencies = (
F5DD369120036D7200308564 /* PBXTargetDependency */,
);
name = StandAloneUITests;
productName = StandAloneUITests;
productReference = F5DD368B20036D7200308564 /* StandAloneUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand Down Expand Up @@ -2717,6 +2764,12 @@
CreatedOnToolsVersion = 7.3;
TestTargetID = F5954E041CBD2E1200117745;
};
F5DD368A20036D7200308564 = {
CreatedOnToolsVersion = 9.2;
DevelopmentTeam = FYD86LA7RE;
ProvisioningStyle = Manual;
TestTargetID = 898743BB1C5847B30084FD93;
};
};
};
buildConfigurationList = 898743B71C5847B30084FD93 /* Build configuration list for PBXProject "DeviceAgent" */;
Expand All @@ -2742,6 +2795,7 @@
F5169CDF1CFD982800252F52 /* TestAppBuildNumber */,
F50BB27A1D73392100264915 /* Permissions */,
F50BB2921D73392200264915 /* Dismiss */,
F5DD368A20036D7200308564 /* StandAloneUITests */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -2827,6 +2881,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
F5DD368920036D7200308564 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -3207,6 +3268,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
F5DD368720036D7200308564 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F5DD368E20036D7200308564 /* StandAloneUITests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
Expand Down Expand Up @@ -3245,6 +3314,11 @@
target = 898743BB1C5847B30084FD93 /* AppStub */;
targetProxy = F5B0A0D41CAD3CBC00E056CE /* PBXContainerItemProxy */;
};
F5DD369120036D7200308564 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 898743BB1C5847B30084FD93 /* AppStub */;
targetProxy = F5DD369020036D7200308564 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
Expand Down Expand Up @@ -3798,6 +3872,58 @@
};
name = Release;
};
F5DD369220036D7200308564 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = FYD86LA7RE;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = StandAloneUITests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = sh.calaba.StandAloneUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "35102a64-7ce2-4d50-86cb-3270f637174c";
PROVISIONING_PROFILE_SPECIFIER = CalabashWildcard;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = AppStub;
};
name = Debug;
};
F5DD369320036D7200308564 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = FYD86LA7RE;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = StandAloneUITests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = sh.calaba.StandAloneUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "35102a64-7ce2-4d50-86cb-3270f637174c";
PROVISIONING_PROFILE_SPECIFIER = CalabashWildcard;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = AppStub;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand Down Expand Up @@ -3891,6 +4017,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
F5DD369420036D7200308564 /* Build configuration list for PBXNativeTarget "StandAloneUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F5DD369220036D7200308564 /* Debug */,
F5DD369320036D7200308564 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
/* End XCConfigurationList section */
};
rootObject = 898743B41C5847B30084FD93 /* Project object */;
Expand Down
10 changes: 10 additions & 0 deletions DeviceAgent.xcworkspace/xcshareddata/xcschemes/AppStub.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
ReferencedContainer = "container:DeviceAgent.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F5DD368A20036D7200308564"
BuildableName = "StandAloneUITests.xctest"
BlueprintName = "StandAloneUITests"
ReferencedContainer = "container:DeviceAgent.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F5DD368A20036D7200308564"
BuildableName = "StandAloneUITests.xctest"
BlueprintName = "StandAloneUITests"
ReferencedContainer = "container:DeviceAgent.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
35 changes: 35 additions & 0 deletions STANDALONE_XCUITEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Stand Alone XCUITest

```shell
$ bin/standalone-xcuitest/test-app.sh

Run arbitrary XCUITests against any .app

Usage:

bin/standalone-xcuitest/test-app.sh path/to/AUT.app [simulator or device UDID]

* .ipa archives must be expanded.
* If no UDID is provided, a default will be used.
* Tests targeting a physical device require the .app
is signed for the device. The app will be installed
on the device as part of the xcodebuild command.
```

This script can be used to run arbitrary XCUITests against any .app.

1. Obtain a .app from the client. If you are given a .ipa, expand it
to reveal the Payload/Example.app.
2. If you are targetting a physical device, resign the Example.app for
the target device. You do not need to install the Example.app on the
device.
3. Add tests to StandAloneUITests/StandAloneUITests.m.
4. Run the script as indicated above (see Usage).

Don't commit changes StandAloneUITests.m.

### Troubleshooting

This technique uses an .xctestrun file.

See `man xcodebuild.xctestrun` for more options.
22 changes: 22 additions & 0 deletions StandAloneUITests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
23 changes: 23 additions & 0 deletions StandAloneUITests/StandAloneUITests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#import <XCTest/XCTest.h>

@interface StandAloneUITests : XCTestCase

@end

@implementation StandAloneUITests

- (void)setUp {
[super setUp];
self.continueAfterFailure = NO;
}

- (void)tearDown {
[super tearDown];
}

- (void)testExample {
[[[XCUIApplication alloc] init] launch];
}

@end
Loading

0 comments on commit 6cb21d8

Please sign in to comment.