Skip to content

Commit f86f569

Browse files
Merge pull request #237 from ably/add-ability-to-run-unit-tests
Add ability to run only the unit tests
2 parents 0294674 + 1cb77c5 commit f86f569

File tree

9 files changed

+268
-3
lines changed

9 files changed

+268
-3
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1610"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "AblyChat"
19+
BuildableName = "AblyChat"
20+
BlueprintName = "AblyChat"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
<BuildActionEntry
25+
buildForTesting = "YES"
26+
buildForRunning = "YES"
27+
buildForProfiling = "YES"
28+
buildForArchiving = "YES"
29+
buildForAnalyzing = "YES">
30+
<BuildableReference
31+
BuildableIdentifier = "primary"
32+
BlueprintIdentifier = "BuildTool"
33+
BuildableName = "BuildTool"
34+
BlueprintName = "BuildTool"
35+
ReferencedContainer = "container:">
36+
</BuildableReference>
37+
</BuildActionEntry>
38+
</BuildActionEntries>
39+
</BuildAction>
40+
<TestAction
41+
buildConfiguration = "Debug"
42+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
43+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
44+
shouldUseLaunchSchemeArgsEnv = "YES">
45+
<TestPlans>
46+
<TestPlanReference
47+
reference = "container:TestPlans/AllTests.xctestplan"
48+
default = "YES">
49+
</TestPlanReference>
50+
<TestPlanReference
51+
reference = "container:TestPlans/UnitTests.xctestplan">
52+
</TestPlanReference>
53+
</TestPlans>
54+
<Testables>
55+
<TestableReference
56+
skipped = "NO">
57+
<BuildableReference
58+
BuildableIdentifier = "primary"
59+
BlueprintIdentifier = "AblyChatTests"
60+
BuildableName = "AblyChatTests"
61+
BlueprintName = "AblyChatTests"
62+
ReferencedContainer = "container:">
63+
</BuildableReference>
64+
</TestableReference>
65+
</Testables>
66+
</TestAction>
67+
<LaunchAction
68+
buildConfiguration = "Debug"
69+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
70+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
71+
launchStyle = "0"
72+
useCustomWorkingDirectory = "NO"
73+
ignoresPersistentStateOnLaunch = "NO"
74+
debugDocumentVersioning = "YES"
75+
debugServiceExtension = "internal"
76+
allowLocationSimulation = "YES">
77+
<MacroExpansion>
78+
<BuildableReference
79+
BuildableIdentifier = "primary"
80+
BlueprintIdentifier = "BuildTool"
81+
BuildableName = "BuildTool"
82+
BlueprintName = "BuildTool"
83+
ReferencedContainer = "container:">
84+
</BuildableReference>
85+
</MacroExpansion>
86+
</LaunchAction>
87+
<ProfileAction
88+
buildConfiguration = "Release"
89+
shouldUseLaunchSchemeArgsEnv = "YES"
90+
savedToolIdentifier = ""
91+
useCustomWorkingDirectory = "NO"
92+
debugDocumentVersioning = "YES">
93+
<MacroExpansion>
94+
<BuildableReference
95+
BuildableIdentifier = "primary"
96+
BlueprintIdentifier = "BuildTool"
97+
BuildableName = "BuildTool"
98+
BlueprintName = "BuildTool"
99+
ReferencedContainer = "container:">
100+
</BuildableReference>
101+
</MacroExpansion>
102+
</ProfileAction>
103+
<AnalyzeAction
104+
buildConfiguration = "Debug">
105+
</AnalyzeAction>
106+
<ArchiveAction
107+
buildConfiguration = "Release"
108+
revealArchiveInOrganizer = "YES">
109+
</ArchiveAction>
110+
</Scheme>

.swiftpm/xcode/xcshareddata/xcschemes/AblyChat.xcscheme

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@
2727
buildConfiguration = "Debug"
2828
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2929
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30-
shouldUseLaunchSchemeArgsEnv = "YES"
31-
shouldAutocreateTestPlan = "YES">
30+
shouldUseLaunchSchemeArgsEnv = "YES">
31+
<TestPlans>
32+
<TestPlanReference
33+
reference = "container:TestPlans/AllTests.xctestplan"
34+
default = "YES">
35+
</TestPlanReference>
36+
<TestPlanReference
37+
reference = "container:TestPlans/UnitTests.xctestplan">
38+
</TestPlanReference>
39+
</TestPlans>
3240
<Testables>
3341
<TestableReference
3442
skipped = "NO">
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1610"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "BuildTool"
19+
BuildableName = "BuildTool"
20+
BlueprintName = "BuildTool"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "BuildTool"
48+
BuildableName = "BuildTool"
49+
BlueprintName = "BuildTool"
50+
ReferencedContainer = "container:">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Release"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "BuildTool"
65+
BuildableName = "BuildTool"
66+
BlueprintName = "BuildTool"
67+
ReferencedContainer = "container:">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Debug">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Release"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>

AblyChat.xcworkspace/contents.xcworkspacedata

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ Either:
1919
- `swift test`, or
2020
- open `AblyChat.xcworkspace` in Xcode and test the `AblyChat` scheme
2121

22+
### Running only the unit tests
23+
24+
There is a test plan called `UnitTests` which will run only the unit tests. These tests are very quick to execute, so it's a useful option to have for quick feedback when developing.
25+
26+
Here's how to set this test plan as the _active test plan_ (the test plan which ⌘U will run):
27+
28+
![Screenshot showing how to activate the UnitTests test plan](/images/unit-tests-test-plan-screenshot.png)
29+
2230
## Linting
2331

2432
To check formatting and code quality, run `swift run BuildTool lint`. Run with `--fix` to first automatically fix things where possible.

TestPlans/AllTests.xctestplan

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"configurations" : [
3+
{
4+
"id" : "A023F5E6-323A-41DE-8909-2E6D5ECA28B1",
5+
"name" : "Configuration 1",
6+
"options" : {
7+
8+
}
9+
}
10+
],
11+
"defaultOptions" : {
12+
13+
},
14+
"testTargets" : [
15+
{
16+
"target" : {
17+
"containerPath" : "container:",
18+
"identifier" : "AblyChatTests",
19+
"name" : "AblyChatTests"
20+
}
21+
}
22+
],
23+
"version" : 1
24+
}

TestPlans/UnitTests.xctestplan

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"configurations" : [
3+
{
4+
"id" : "5E4FC24B-44CD-4F7C-93C7-E07A7B219D5A",
5+
"name" : "Configuration 1",
6+
"options" : {
7+
8+
}
9+
}
10+
],
11+
"defaultOptions" : {
12+
"testTimeoutsEnabled" : true
13+
},
14+
"testTargets" : [
15+
{
16+
"skippedTags" : {
17+
"tags" : [
18+
".integration"
19+
]
20+
},
21+
"target" : {
22+
"containerPath" : "container:",
23+
"identifier" : "AblyChatTests",
24+
"name" : "AblyChatTests"
25+
}
26+
}
27+
],
28+
"version" : 1
29+
}

Tests/AblyChatTests/IntegrationTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ import Ably
22
@testable import AblyChat
33
import Testing
44

5+
extension Tag {
6+
/// Any test that is not a unit test. This usually implies that it has a non-trivial execution time.
7+
@Tag static var integration: Self
8+
}
9+
510
/// Some very basic integration tests, just to check that things are kind of working.
611
///
712
/// It would be nice to give this a time limit, but unfortunately the `timeLimit` trait is only available on iOS 16 etc and above. CodeRabbit suggested writing a timeout function myself and wrapping the contents of the test in it, but I didn’t have time to try understanding its suggested code, so it can wait.
8-
@Suite
13+
@Suite(.tags(.integration))
914
struct IntegrationTests {
1015
private class AblyCocoaLogger: ARTLog {
1116
private let label: String
116 KB
Loading

0 commit comments

Comments
 (0)