Skip to content

Commit

Permalink
refactor(swift): move swift smoke-tests to an ios example app (#7)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?

This change moves the swift smoke tests from a regular unit test into an
ios example app. This is a necessary prerequisite to being able to test
any UI auto-instrumentation. It also brings things more into line with
the Android smoke tests.

Note: The library still targets ios, macos, watchos, etc, but the new
smoke test is explicitly iOS. We'll eventually want to add smoke tests
for other platforms we support. But the implementation of
auto-instrumentation is likely to vary significantly by platform. For
now, we'll just focus on iOS.

## Short description of the changes

The code changes themselves are pretty minimal. Instead of the test
directly sending a span, for example, it now clicks the button:
`app.buttons["Send simple span"].tap()`.

The complicated part is the project structure. This repo is a swift
package, which comes with a few constraints:
* The library itself has to be at the top level of the repo.
* iOS app targets cannot be part of a swift package.

To work around this, I had to create a .xcodeproj for the example app in
a subdirectory. Unfortunately, Xcode projects can't depend on libraries
in their parent directories. So, to work around _that_, I had to create
a `.xcworkspace` to contain both the library and the example app
projects. That fixes the dependency problem, and also provides the
schemas for `xcodebuild` to run the tests from the command line. The
repo structure ends up looking like this:

```
repo/
    Workspace.xcworkspace
    Package.swift                 # library package definition
    Sources/
        Honeycomb/                # library source
    Tests/
        Honeycomb/                # library unit tests
    Examples/
        SmokeTest/
            SmokeTest.xcodeproj   # example app project
            SmokeTest/            # example app source
            SmokeTestTests/       # example app unit tests (unused placeholder)
            SmokeTestUITests/     # example app smoke tests
```

There is also a minor fix to rename "Api" to "API" in API names, to
conform with platform conventions.

## How to verify that this has the expected result

`make smoke` still works the same.
  • Loading branch information
beekhc authored Sep 10, 2024
1 parent 1be7ea5 commit 74af9d0
Show file tree
Hide file tree
Showing 24 changed files with 1,076 additions and 76 deletions.
54 changes: 54 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/HoneycombTests.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "HoneycombTests"
BuildableName = "HoneycombTests"
BlueprintName = "HoneycombTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Loading

0 comments on commit 74af9d0

Please sign in to comment.