├── .gitignore
├── LICENSE
├── Package.swift
├── README.md
├── XCTestExtensions.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── shindyu.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
├── xcshareddata
│ └── xcschemes
│ │ └── XCTestExtensions.xcscheme
└── xcuserdata
│ └── shindyu.xcuserdatad
│ └── xcschemes
│ └── xcschememanagement.plist
├── XCTestExtensions
├── Info.plist
├── XCTAssertEventually.swift
├── XCTWaiter+.swift
├── XCTestExtensions.h
└── XCTxContext.swift
├── XCTestExtensionsTests
├── Info.plist
├── XCTAssertEventuallyTests.swift
└── XCTxContextTests.swift
└── img
└── method_completion.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | ## Playgrounds
32 | timeline.xctimeline
33 | playground.xcworkspace
34 |
35 | # Swift Package Manager
36 | #
37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
38 | # Packages/
39 | # Package.pins
40 | .build/
41 |
42 | # CocoaPods
43 | #
44 | # We recommend against adding the Pods directory to your .gitignore. However
45 | # you should judge for yourself, the pros and cons are mentioned at:
46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
47 | #
48 | # Pods/
49 |
50 | # Carthage
51 | #
52 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
53 | # Carthage/Checkouts
54 |
55 | Carthage/Build
56 |
57 | # fastlane
58 | #
59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
60 | # screenshots whenever they are needed.
61 | # For more information about the recommended setup visit:
62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
63 |
64 | fastlane/report.xml
65 | fastlane/Preview.html
66 | fastlane/screenshots
67 | fastlane/test_output
68 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 shindyu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.5
2 | // The swift-tools-version declares the minimum version of Swift required to build this package.
3 |
4 | import PackageDescription
5 |
6 | let package = Package(
7 | name: "XCTestExtensions",
8 | platforms: [.iOS(.v9)],
9 | products: [
10 | .library(
11 | name: "XCTestExtensions",
12 | targets: ["XCTestExtensions"]),
13 | ],
14 | dependencies: [
15 | ],
16 | targets: [
17 | .target(
18 | name: "XCTestExtensions",
19 | dependencies: [],
20 | path: "XCTestExtensions"
21 | ),
22 | .testTarget(
23 | name: "XCTestExtensionsTests",
24 | dependencies: ["XCTestExtensions"],
25 | path: "XCTestExtensionsTests"
26 | ),
27 | ]
28 | )
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # XCTestExtensions
2 | [](https://app.bitrise.io/app/d0839dd24a68d8bb)
3 |
4 | # Features
5 | - [x] `XCTAssertEventually` (that convenient assertions for writing Unit Test).
6 |
7 | - Use "XCTAssertEventually", you can write asynchronous assertions very easily and intuitively, like [Nimble](https://github.com/Quick/Nimble)'s toEventually.
8 |
9 | - [x] `XCTxContext` (It is a wrapper of XCTContext.runActivity.)
10 | - `XCTxContext` can internally test setup and tearDown of TestClass. Of course you can not do it.
11 |
12 | # Installation
13 | ## Installing with Carthage
14 |
15 | Add to `Cartfile.private`
16 | ```
17 | github "shindyu/XCTestExtensions"
18 | ```
19 |
20 | # Usage
21 | Import `XCTestExtensions` to Unit tests files:
22 | ```swift
23 | import XCTestExtensions
24 | ```
25 |
26 |
27 | Use `XCTestExtensions`'s extensions in your tests:
28 |
29 |
30 |
31 | For example, Applying it to [the asynchronous test of the official document of apple](https://developer.apple.com/documentation/xctest/asynchronous_tests_and_expectations/testing_asynchronous_operations_with_expectations), it can be described as follows:
32 | ```swift
33 | func testDownloadWebData_UsingXCTAssertEventually() {
34 | XCTxContext("you can describe context") {
35 | let url = URL(string: "https://apple.com")!
36 |
37 | var downloadData: Data?
38 |
39 | let dataTask = URLSession.shared.dataTask(with: url) { (data, _, _) in
40 | downloadData = data
41 | }
42 |
43 | dataTask.resume()
44 |
45 | XCTAssertNotNilEventually(downloadData)
46 | }
47 | }
48 | ```
49 |
50 | # Contributing
51 | Bug reports and pull requests are welcome on GitHub at https://github.com/shindyu/XCTestExtensions
52 |
53 | # License
54 | XCTestExtensions is available as open source under the terms of the [MIT License](https://github.com/shindyu/XCTestExtensions/blob/master/LICENSE).
55 |
--------------------------------------------------------------------------------
/XCTestExtensions.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 48;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1791BEED21C0B826002FD379 /* XCTxContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1791BEEC21C0B826002FD379 /* XCTxContext.swift */; };
11 | 1791BEEF21C0B8C0002FD379 /* XCTxContextTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1791BEEE21C0B8C0002FD379 /* XCTxContextTests.swift */; };
12 | 512B10ED1FECCBD60062B991 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 512B10EC1FECCBD60062B991 /* XCTest.framework */; };
13 | 519E3D5E1FECAFBA009DD741 /* XCTestExtensions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 519E3D541FECAFBA009DD741 /* XCTestExtensions.framework */; };
14 | 519E3D651FECAFBA009DD741 /* XCTestExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 519E3D571FECAFBA009DD741 /* XCTestExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
15 | 519E3D6F1FECAFF5009DD741 /* XCTAssertEventually.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519E3D6E1FECAFF5009DD741 /* XCTAssertEventually.swift */; };
16 | 519E3D711FECB025009DD741 /* XCTWaiter+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519E3D701FECB025009DD741 /* XCTWaiter+.swift */; };
17 | 519E3D731FECB0AC009DD741 /* XCTAssertEventuallyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519E3D721FECB0AC009DD741 /* XCTAssertEventuallyTests.swift */; };
18 | 519E3D9F1FECBA40009DD741 /* XCTAssertEventually.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519E3D6E1FECAFF5009DD741 /* XCTAssertEventually.swift */; };
19 | 519E3DA01FECBA43009DD741 /* XCTWaiter+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519E3D701FECB025009DD741 /* XCTWaiter+.swift */; };
20 | /* End PBXBuildFile section */
21 |
22 | /* Begin PBXContainerItemProxy section */
23 | 519E3D5F1FECAFBA009DD741 /* PBXContainerItemProxy */ = {
24 | isa = PBXContainerItemProxy;
25 | containerPortal = 519E3D4B1FECAFBA009DD741 /* Project object */;
26 | proxyType = 1;
27 | remoteGlobalIDString = 519E3D531FECAFBA009DD741;
28 | remoteInfo = XCTestExtensions;
29 | };
30 | /* End PBXContainerItemProxy section */
31 |
32 | /* Begin PBXFileReference section */
33 | 1791BEEC21C0B826002FD379 /* XCTxContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTxContext.swift; sourceTree = ""; };
34 | 1791BEEE21C0B8C0002FD379 /* XCTxContextTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTxContextTests.swift; sourceTree = ""; };
35 | 512B10EC1FECCBD60062B991 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
36 | 519E3D541FECAFBA009DD741 /* XCTestExtensions.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = XCTestExtensions.framework; sourceTree = BUILT_PRODUCTS_DIR; };
37 | 519E3D571FECAFBA009DD741 /* XCTestExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XCTestExtensions.h; sourceTree = ""; };
38 | 519E3D581FECAFBA009DD741 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
39 | 519E3D5D1FECAFBA009DD741 /* XCTestExtensionsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XCTestExtensionsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
40 | 519E3D641FECAFBA009DD741 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
41 | 519E3D6E1FECAFF5009DD741 /* XCTAssertEventually.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTAssertEventually.swift; sourceTree = ""; };
42 | 519E3D701FECB025009DD741 /* XCTWaiter+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTWaiter+.swift"; sourceTree = ""; };
43 | 519E3D721FECB0AC009DD741 /* XCTAssertEventuallyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTAssertEventuallyTests.swift; sourceTree = ""; };
44 | CDCFEAF62768979200B5981F /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; };
45 | /* End PBXFileReference section */
46 |
47 | /* Begin PBXFrameworksBuildPhase section */
48 | 519E3D501FECAFBA009DD741 /* Frameworks */ = {
49 | isa = PBXFrameworksBuildPhase;
50 | buildActionMask = 2147483647;
51 | files = (
52 | 512B10ED1FECCBD60062B991 /* XCTest.framework in Frameworks */,
53 | );
54 | runOnlyForDeploymentPostprocessing = 0;
55 | };
56 | 519E3D5A1FECAFBA009DD741 /* Frameworks */ = {
57 | isa = PBXFrameworksBuildPhase;
58 | buildActionMask = 2147483647;
59 | files = (
60 | 519E3D5E1FECAFBA009DD741 /* XCTestExtensions.framework in Frameworks */,
61 | );
62 | runOnlyForDeploymentPostprocessing = 0;
63 | };
64 | /* End PBXFrameworksBuildPhase section */
65 |
66 | /* Begin PBXGroup section */
67 | 519E3D4A1FECAFBA009DD741 = {
68 | isa = PBXGroup;
69 | children = (
70 | CDCFEAF62768979200B5981F /* Package.swift */,
71 | 519E3D561FECAFBA009DD741 /* XCTestExtensions */,
72 | 519E3D611FECAFBA009DD741 /* XCTestExtensionsTests */,
73 | 519E3D551FECAFBA009DD741 /* Products */,
74 | 519E3D9C1FECB753009DD741 /* Frameworks */,
75 | );
76 | sourceTree = "";
77 | };
78 | 519E3D551FECAFBA009DD741 /* Products */ = {
79 | isa = PBXGroup;
80 | children = (
81 | 519E3D541FECAFBA009DD741 /* XCTestExtensions.framework */,
82 | 519E3D5D1FECAFBA009DD741 /* XCTestExtensionsTests.xctest */,
83 | );
84 | name = Products;
85 | sourceTree = "";
86 | };
87 | 519E3D561FECAFBA009DD741 /* XCTestExtensions */ = {
88 | isa = PBXGroup;
89 | children = (
90 | 519E3D571FECAFBA009DD741 /* XCTestExtensions.h */,
91 | 519E3D581FECAFBA009DD741 /* Info.plist */,
92 | 519E3D6E1FECAFF5009DD741 /* XCTAssertEventually.swift */,
93 | 1791BEEC21C0B826002FD379 /* XCTxContext.swift */,
94 | 519E3D701FECB025009DD741 /* XCTWaiter+.swift */,
95 | );
96 | path = XCTestExtensions;
97 | sourceTree = "";
98 | };
99 | 519E3D611FECAFBA009DD741 /* XCTestExtensionsTests */ = {
100 | isa = PBXGroup;
101 | children = (
102 | 519E3D641FECAFBA009DD741 /* Info.plist */,
103 | 519E3D721FECB0AC009DD741 /* XCTAssertEventuallyTests.swift */,
104 | 1791BEEE21C0B8C0002FD379 /* XCTxContextTests.swift */,
105 | );
106 | path = XCTestExtensionsTests;
107 | sourceTree = "";
108 | };
109 | 519E3D9C1FECB753009DD741 /* Frameworks */ = {
110 | isa = PBXGroup;
111 | children = (
112 | 512B10EC1FECCBD60062B991 /* XCTest.framework */,
113 | );
114 | name = Frameworks;
115 | sourceTree = "";
116 | };
117 | /* End PBXGroup section */
118 |
119 | /* Begin PBXHeadersBuildPhase section */
120 | 519E3D511FECAFBA009DD741 /* Headers */ = {
121 | isa = PBXHeadersBuildPhase;
122 | buildActionMask = 2147483647;
123 | files = (
124 | 519E3D651FECAFBA009DD741 /* XCTestExtensions.h in Headers */,
125 | );
126 | runOnlyForDeploymentPostprocessing = 0;
127 | };
128 | /* End PBXHeadersBuildPhase section */
129 |
130 | /* Begin PBXNativeTarget section */
131 | 519E3D531FECAFBA009DD741 /* XCTestExtensions */ = {
132 | isa = PBXNativeTarget;
133 | buildConfigurationList = 519E3D681FECAFBA009DD741 /* Build configuration list for PBXNativeTarget "XCTestExtensions" */;
134 | buildPhases = (
135 | 519E3D4F1FECAFBA009DD741 /* Sources */,
136 | 519E3D501FECAFBA009DD741 /* Frameworks */,
137 | 519E3D511FECAFBA009DD741 /* Headers */,
138 | 519E3D521FECAFBA009DD741 /* Resources */,
139 | );
140 | buildRules = (
141 | );
142 | dependencies = (
143 | );
144 | name = XCTestExtensions;
145 | productName = XCTestExtensions;
146 | productReference = 519E3D541FECAFBA009DD741 /* XCTestExtensions.framework */;
147 | productType = "com.apple.product-type.framework";
148 | };
149 | 519E3D5C1FECAFBA009DD741 /* XCTestExtensionsTests */ = {
150 | isa = PBXNativeTarget;
151 | buildConfigurationList = 519E3D6B1FECAFBA009DD741 /* Build configuration list for PBXNativeTarget "XCTestExtensionsTests" */;
152 | buildPhases = (
153 | 519E3D591FECAFBA009DD741 /* Sources */,
154 | 519E3D5A1FECAFBA009DD741 /* Frameworks */,
155 | 519E3D5B1FECAFBA009DD741 /* Resources */,
156 | );
157 | buildRules = (
158 | );
159 | dependencies = (
160 | 519E3D601FECAFBA009DD741 /* PBXTargetDependency */,
161 | );
162 | name = XCTestExtensionsTests;
163 | productName = XCTestExtensionsTests;
164 | productReference = 519E3D5D1FECAFBA009DD741 /* XCTestExtensionsTests.xctest */;
165 | productType = "com.apple.product-type.bundle.unit-test";
166 | };
167 | /* End PBXNativeTarget section */
168 |
169 | /* Begin PBXProject section */
170 | 519E3D4B1FECAFBA009DD741 /* Project object */ = {
171 | isa = PBXProject;
172 | attributes = {
173 | LastSwiftUpdateCheck = 0920;
174 | LastUpgradeCheck = 1310;
175 | ORGANIZATIONNAME = shindyu;
176 | TargetAttributes = {
177 | 519E3D531FECAFBA009DD741 = {
178 | CreatedOnToolsVersion = 9.2;
179 | LastSwiftMigration = 1010;
180 | ProvisioningStyle = Automatic;
181 | };
182 | 519E3D5C1FECAFBA009DD741 = {
183 | CreatedOnToolsVersion = 9.2;
184 | LastSwiftMigration = 1010;
185 | ProvisioningStyle = Automatic;
186 | };
187 | };
188 | };
189 | buildConfigurationList = 519E3D4E1FECAFBA009DD741 /* Build configuration list for PBXProject "XCTestExtensions" */;
190 | compatibilityVersion = "Xcode 8.0";
191 | developmentRegion = en;
192 | hasScannedForEncodings = 0;
193 | knownRegions = (
194 | en,
195 | Base,
196 | );
197 | mainGroup = 519E3D4A1FECAFBA009DD741;
198 | productRefGroup = 519E3D551FECAFBA009DD741 /* Products */;
199 | projectDirPath = "";
200 | projectRoot = "";
201 | targets = (
202 | 519E3D531FECAFBA009DD741 /* XCTestExtensions */,
203 | 519E3D5C1FECAFBA009DD741 /* XCTestExtensionsTests */,
204 | );
205 | };
206 | /* End PBXProject section */
207 |
208 | /* Begin PBXResourcesBuildPhase section */
209 | 519E3D521FECAFBA009DD741 /* Resources */ = {
210 | isa = PBXResourcesBuildPhase;
211 | buildActionMask = 2147483647;
212 | files = (
213 | );
214 | runOnlyForDeploymentPostprocessing = 0;
215 | };
216 | 519E3D5B1FECAFBA009DD741 /* Resources */ = {
217 | isa = PBXResourcesBuildPhase;
218 | buildActionMask = 2147483647;
219 | files = (
220 | );
221 | runOnlyForDeploymentPostprocessing = 0;
222 | };
223 | /* End PBXResourcesBuildPhase section */
224 |
225 | /* Begin PBXSourcesBuildPhase section */
226 | 519E3D4F1FECAFBA009DD741 /* Sources */ = {
227 | isa = PBXSourcesBuildPhase;
228 | buildActionMask = 2147483647;
229 | files = (
230 | 1791BEED21C0B826002FD379 /* XCTxContext.swift in Sources */,
231 | 519E3D6F1FECAFF5009DD741 /* XCTAssertEventually.swift in Sources */,
232 | 519E3D711FECB025009DD741 /* XCTWaiter+.swift in Sources */,
233 | );
234 | runOnlyForDeploymentPostprocessing = 0;
235 | };
236 | 519E3D591FECAFBA009DD741 /* Sources */ = {
237 | isa = PBXSourcesBuildPhase;
238 | buildActionMask = 2147483647;
239 | files = (
240 | 519E3D731FECB0AC009DD741 /* XCTAssertEventuallyTests.swift in Sources */,
241 | 1791BEEF21C0B8C0002FD379 /* XCTxContextTests.swift in Sources */,
242 | 519E3DA01FECBA43009DD741 /* XCTWaiter+.swift in Sources */,
243 | 519E3D9F1FECBA40009DD741 /* XCTAssertEventually.swift in Sources */,
244 | );
245 | runOnlyForDeploymentPostprocessing = 0;
246 | };
247 | /* End PBXSourcesBuildPhase section */
248 |
249 | /* Begin PBXTargetDependency section */
250 | 519E3D601FECAFBA009DD741 /* PBXTargetDependency */ = {
251 | isa = PBXTargetDependency;
252 | target = 519E3D531FECAFBA009DD741 /* XCTestExtensions */;
253 | targetProxy = 519E3D5F1FECAFBA009DD741 /* PBXContainerItemProxy */;
254 | };
255 | /* End PBXTargetDependency section */
256 |
257 | /* Begin XCBuildConfiguration section */
258 | 519E3D661FECAFBA009DD741 /* Debug */ = {
259 | isa = XCBuildConfiguration;
260 | buildSettings = {
261 | ALWAYS_SEARCH_USER_PATHS = NO;
262 | CLANG_ANALYZER_NONNULL = YES;
263 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
264 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
265 | CLANG_CXX_LIBRARY = "libc++";
266 | CLANG_ENABLE_MODULES = YES;
267 | CLANG_ENABLE_OBJC_ARC = YES;
268 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
269 | CLANG_WARN_BOOL_CONVERSION = YES;
270 | CLANG_WARN_COMMA = YES;
271 | CLANG_WARN_CONSTANT_CONVERSION = YES;
272 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
274 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
275 | CLANG_WARN_EMPTY_BODY = YES;
276 | CLANG_WARN_ENUM_CONVERSION = YES;
277 | CLANG_WARN_INFINITE_RECURSION = YES;
278 | CLANG_WARN_INT_CONVERSION = YES;
279 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
280 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
281 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
282 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
283 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
284 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
285 | CLANG_WARN_STRICT_PROTOTYPES = YES;
286 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
287 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
288 | CLANG_WARN_UNREACHABLE_CODE = YES;
289 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
290 | CODE_SIGN_IDENTITY = "iPhone Developer";
291 | COPY_PHASE_STRIP = NO;
292 | CURRENT_PROJECT_VERSION = 1;
293 | DEBUG_INFORMATION_FORMAT = dwarf;
294 | ENABLE_STRICT_OBJC_MSGSEND = YES;
295 | ENABLE_TESTABILITY = YES;
296 | GCC_C_LANGUAGE_STANDARD = gnu11;
297 | GCC_DYNAMIC_NO_PIC = NO;
298 | GCC_NO_COMMON_BLOCKS = YES;
299 | GCC_OPTIMIZATION_LEVEL = 0;
300 | GCC_PREPROCESSOR_DEFINITIONS = (
301 | "DEBUG=1",
302 | "$(inherited)",
303 | );
304 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
305 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
306 | GCC_WARN_UNDECLARED_SELECTOR = YES;
307 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
308 | GCC_WARN_UNUSED_FUNCTION = YES;
309 | GCC_WARN_UNUSED_VARIABLE = YES;
310 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
311 | MTL_ENABLE_DEBUG_INFO = YES;
312 | ONLY_ACTIVE_ARCH = YES;
313 | SDKROOT = iphoneos;
314 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
315 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
316 | VERSIONING_SYSTEM = "apple-generic";
317 | VERSION_INFO_PREFIX = "";
318 | };
319 | name = Debug;
320 | };
321 | 519E3D671FECAFBA009DD741 /* Release */ = {
322 | isa = XCBuildConfiguration;
323 | buildSettings = {
324 | ALWAYS_SEARCH_USER_PATHS = NO;
325 | CLANG_ANALYZER_NONNULL = YES;
326 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
327 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
328 | CLANG_CXX_LIBRARY = "libc++";
329 | CLANG_ENABLE_MODULES = YES;
330 | CLANG_ENABLE_OBJC_ARC = YES;
331 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
332 | CLANG_WARN_BOOL_CONVERSION = YES;
333 | CLANG_WARN_COMMA = YES;
334 | CLANG_WARN_CONSTANT_CONVERSION = YES;
335 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
336 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
337 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
338 | CLANG_WARN_EMPTY_BODY = YES;
339 | CLANG_WARN_ENUM_CONVERSION = YES;
340 | CLANG_WARN_INFINITE_RECURSION = YES;
341 | CLANG_WARN_INT_CONVERSION = YES;
342 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
343 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
344 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
345 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
346 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
347 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
348 | CLANG_WARN_STRICT_PROTOTYPES = YES;
349 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
350 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
351 | CLANG_WARN_UNREACHABLE_CODE = YES;
352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
353 | CODE_SIGN_IDENTITY = "iPhone Developer";
354 | COPY_PHASE_STRIP = NO;
355 | CURRENT_PROJECT_VERSION = 1;
356 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
357 | ENABLE_NS_ASSERTIONS = NO;
358 | ENABLE_STRICT_OBJC_MSGSEND = YES;
359 | GCC_C_LANGUAGE_STANDARD = gnu11;
360 | GCC_NO_COMMON_BLOCKS = YES;
361 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
362 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
363 | GCC_WARN_UNDECLARED_SELECTOR = YES;
364 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
365 | GCC_WARN_UNUSED_FUNCTION = YES;
366 | GCC_WARN_UNUSED_VARIABLE = YES;
367 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
368 | MTL_ENABLE_DEBUG_INFO = NO;
369 | SDKROOT = iphoneos;
370 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
371 | VALIDATE_PRODUCT = YES;
372 | VERSIONING_SYSTEM = "apple-generic";
373 | VERSION_INFO_PREFIX = "";
374 | };
375 | name = Release;
376 | };
377 | 519E3D691FECAFBA009DD741 /* Debug */ = {
378 | isa = XCBuildConfiguration;
379 | buildSettings = {
380 | CLANG_ENABLE_MODULES = YES;
381 | CODE_SIGN_IDENTITY = "";
382 | CODE_SIGN_STYLE = Automatic;
383 | DEFINES_MODULE = YES;
384 | DEVELOPMENT_TEAM = 653H53HHBU;
385 | DYLIB_COMPATIBILITY_VERSION = 1;
386 | DYLIB_CURRENT_VERSION = 1;
387 | DYLIB_INSTALL_NAME_BASE = "@rpath";
388 | ENABLE_BITCODE = NO;
389 | FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks";
390 | INFOPLIST_FILE = XCTestExtensions/Info.plist;
391 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
392 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
393 | ONLY_ACTIVE_ARCH = NO;
394 | OTHER_CFLAGS = "";
395 | PRODUCT_BUNDLE_IDENTIFIER = com.shindyu.XCTestExtensions;
396 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
397 | SKIP_INSTALL = YES;
398 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
399 | SWIFT_VERSION = 5.0;
400 | TARGETED_DEVICE_FAMILY = "1,2";
401 | };
402 | name = Debug;
403 | };
404 | 519E3D6A1FECAFBA009DD741 /* Release */ = {
405 | isa = XCBuildConfiguration;
406 | buildSettings = {
407 | CLANG_ENABLE_MODULES = YES;
408 | CODE_SIGN_IDENTITY = "";
409 | CODE_SIGN_STYLE = Automatic;
410 | DEFINES_MODULE = YES;
411 | DEVELOPMENT_TEAM = 653H53HHBU;
412 | DYLIB_COMPATIBILITY_VERSION = 1;
413 | DYLIB_CURRENT_VERSION = 1;
414 | DYLIB_INSTALL_NAME_BASE = "@rpath";
415 | ENABLE_BITCODE = NO;
416 | ENABLE_TESTABILITY = NO;
417 | FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks";
418 | INFOPLIST_FILE = XCTestExtensions/Info.plist;
419 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
420 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
421 | ONLY_ACTIVE_ARCH = NO;
422 | OTHER_CFLAGS = "";
423 | PRODUCT_BUNDLE_IDENTIFIER = com.shindyu.XCTestExtensions;
424 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
425 | SKIP_INSTALL = YES;
426 | SWIFT_VERSION = 5.0;
427 | TARGETED_DEVICE_FAMILY = "1,2";
428 | };
429 | name = Release;
430 | };
431 | 519E3D6C1FECAFBA009DD741 /* Debug */ = {
432 | isa = XCBuildConfiguration;
433 | buildSettings = {
434 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
435 | CODE_SIGN_STYLE = Automatic;
436 | DEVELOPMENT_TEAM = 653H53HHBU;
437 | INFOPLIST_FILE = XCTestExtensionsTests/Info.plist;
438 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
439 | PRODUCT_BUNDLE_IDENTIFIER = com.shindyu.XCTestExtensionsTests;
440 | PRODUCT_NAME = "$(TARGET_NAME)";
441 | SWIFT_VERSION = 5.0;
442 | TARGETED_DEVICE_FAMILY = "1,2";
443 | };
444 | name = Debug;
445 | };
446 | 519E3D6D1FECAFBA009DD741 /* Release */ = {
447 | isa = XCBuildConfiguration;
448 | buildSettings = {
449 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
450 | CODE_SIGN_STYLE = Automatic;
451 | DEVELOPMENT_TEAM = 653H53HHBU;
452 | INFOPLIST_FILE = XCTestExtensionsTests/Info.plist;
453 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
454 | PRODUCT_BUNDLE_IDENTIFIER = com.shindyu.XCTestExtensionsTests;
455 | PRODUCT_NAME = "$(TARGET_NAME)";
456 | SWIFT_VERSION = 5.0;
457 | TARGETED_DEVICE_FAMILY = "1,2";
458 | };
459 | name = Release;
460 | };
461 | /* End XCBuildConfiguration section */
462 |
463 | /* Begin XCConfigurationList section */
464 | 519E3D4E1FECAFBA009DD741 /* Build configuration list for PBXProject "XCTestExtensions" */ = {
465 | isa = XCConfigurationList;
466 | buildConfigurations = (
467 | 519E3D661FECAFBA009DD741 /* Debug */,
468 | 519E3D671FECAFBA009DD741 /* Release */,
469 | );
470 | defaultConfigurationIsVisible = 0;
471 | defaultConfigurationName = Release;
472 | };
473 | 519E3D681FECAFBA009DD741 /* Build configuration list for PBXNativeTarget "XCTestExtensions" */ = {
474 | isa = XCConfigurationList;
475 | buildConfigurations = (
476 | 519E3D691FECAFBA009DD741 /* Debug */,
477 | 519E3D6A1FECAFBA009DD741 /* Release */,
478 | );
479 | defaultConfigurationIsVisible = 0;
480 | defaultConfigurationName = Release;
481 | };
482 | 519E3D6B1FECAFBA009DD741 /* Build configuration list for PBXNativeTarget "XCTestExtensionsTests" */ = {
483 | isa = XCConfigurationList;
484 | buildConfigurations = (
485 | 519E3D6C1FECAFBA009DD741 /* Debug */,
486 | 519E3D6D1FECAFBA009DD741 /* Release */,
487 | );
488 | defaultConfigurationIsVisible = 0;
489 | defaultConfigurationName = Release;
490 | };
491 | /* End XCConfigurationList section */
492 | };
493 | rootObject = 519E3D4B1FECAFBA009DD741 /* Project object */;
494 | }
495 |
--------------------------------------------------------------------------------
/XCTestExtensions.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/XCTestExtensions.xcodeproj/project.xcworkspace/xcuserdata/shindyu.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shindyu/XCTestExtensions/8a320980a4f59c92c92687d7e7f5547b85f029aa/XCTestExtensions.xcodeproj/project.xcworkspace/xcuserdata/shindyu.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/XCTestExtensions.xcodeproj/xcshareddata/xcschemes/XCTestExtensions.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
42 |
48 |
49 |
50 |
51 |
52 |
62 |
63 |
69 |
70 |
71 |
72 |
78 |
79 |
85 |
86 |
87 |
88 |
90 |
91 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/XCTestExtensions.xcodeproj/xcuserdata/shindyu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | XCTestExtensions.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 519E3D531FECAFBA009DD741
16 |
17 | primary
18 |
19 |
20 | 519E3D5C1FECAFBA009DD741
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/XCTestExtensions/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 | NSPrincipalClass
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/XCTestExtensions/XCTAssertEventually.swift:
--------------------------------------------------------------------------------
1 | //
2 | // XCTAssertEventually.swift
3 | // XCTestExtensions
4 | //
5 | // Created by shindyu on 2017/12/22.
6 | // Copyright © 2017年 shindyu. All rights reserved.
7 | //
8 | import Foundation
9 | import XCTest
10 |
11 | /// Asynchronously, Asserts that an expression is true.
12 | ///
13 | /// - Parameters:
14 | /// - expression: An expression of boolean type.
15 | /// - message: An optional description of the failure.
16 | /// - pollTimeout: Timeout of Polling.
17 | /// - pollCount: Number of Polling.
18 | /// - pollInterval: Polling interval.
19 | /// - file: The file in which failure occurred. Defaults to the file name of the test case in which this function was called
20 | /// - line: The line number on which failure occurred. Defaults to the line number on which this function was called.
21 | public func XCTAssertEventually(_ expression: @escaping @autoclosure () throws -> Bool, message: String = "", pollTimeout: TimeInterval = 10.0, pollCount: Int = 10, pollInterval: TimeInterval = 0.1, file: StaticString = #file, line: UInt = #line) {
22 | XCTAssertTrueEventually(try expression(), message: message, pollTimeout: pollTimeout, pollCount: pollCount, pollInterval: pollInterval, file: file, line: line)
23 | }
24 |
25 | /// Asynchronously, Asserts that an expression is true.
26 | ///
27 | /// - Parameters:
28 | /// - expression: An expression of boolean type.
29 | /// - message: An optional description of the failure.
30 | /// - pollTimeout: Timeout of Polling.
31 | /// - pollCount: Number of Polling.
32 | /// - pollInterval: Polling interval.
33 | /// - file: The file in which failure occurred. Defaults to the file name of the test case in which this function was called
34 | /// - line: The line number on which failure occurred. Defaults to the line number on which this function was called.
35 | public func XCTAssertTrueEventually(_ expression: @escaping @autoclosure () throws -> Bool, message: String = "", pollTimeout: TimeInterval = 10.0, pollCount: Int = 10, pollInterval: TimeInterval = 0.1, file: StaticString = #file, line: UInt = #line) {
36 | var result: XCTWaiter.Result = .timedOut
37 |
38 | for _ in 0.. Bool, message: String = "", pollTimeout: TimeInterval = 10.0, pollCount: Int = 10, pollInterval: TimeInterval = 0.1, file: StaticString = #file, line: UInt = #line) {
81 | var result: XCTWaiter.Result = .timedOut
82 |
83 | for _ in 0..(_ expression1: @escaping @autoclosure () throws -> T?, _ expression2: @escaping @autoclosure () throws -> T?, message: String = "", pollTimeout: TimeInterval = 10.0, pollCount: Int = 10, pollInterval: TimeInterval = 0.1, file: StaticString = #file, line: UInt = #line) {
127 | var value1: T?
128 | var value2: T?
129 | var result: XCTWaiter.Result = .timedOut
130 |
131 | for _ in 0..(_ expression1: @escaping @autoclosure () throws -> [T]?, _ expression2: @escaping @autoclosure () throws -> [T]?, message: String = "", pollTimeout: TimeInterval = 10.0, pollCount: Int = 10, pollInterval: TimeInterval = 0.1, file: StaticString = #file, line: UInt = #line) {
177 | var value1: [T]?
178 | var value2: [T]?
179 | var result: XCTWaiter.Result = .timedOut
180 |
181 | for _ in 0..(_ expression: @escaping @autoclosure () throws -> T?, message: String = "", pollTimeout: TimeInterval = 10.0, pollCount: Int = 10, pollInterval: TimeInterval = 0.1, file: StaticString = #file, line: UInt = #line) {
227 | var value: T?
228 | var result: XCTWaiter.Result = .timedOut
229 |
230 | for _ in 0..(_ expression: @escaping @autoclosure () throws -> [T]?, message: String = "", pollTimeout: TimeInterval = 10.0, pollCount: Int = 10, pollInterval: TimeInterval = 0.1, file: StaticString = #file, line: UInt = #line) {
274 | var value: [T]?
275 | var result: XCTWaiter.Result = .timedOut
276 |
277 | for _ in 0..(_ expression: @escaping @autoclosure () throws -> T?, message: String = "", pollTimeout: TimeInterval = 10.0, pollCount: Int = 10, pollInterval: TimeInterval = 0.1, file: StaticString = #file, line: UInt = #line) {
321 | var value: T?
322 | var result: XCTWaiter.Result = .timedOut
323 |
324 | for _ in 0..(_ expression: @escaping @autoclosure () throws -> [T]?, message: String = "", pollTimeout: TimeInterval = 10.0, pollCount: Int = 10, pollInterval: TimeInterval = 0.1, file: StaticString = #file, line: UInt = #line) {
368 | var value: [T]?
369 | var result: XCTWaiter.Result = .timedOut
370 |
371 | for _ in 0.. String {
13 | switch self {
14 | case .completed:
15 | return "completed"
16 | case .timedOut:
17 | return "timedOut"
18 | case .incorrectOrder:
19 | return "incorrectOrder"
20 | case .invertedFulfillment:
21 | return "invertedFulfillment"
22 | case .interrupted:
23 | return "interrupted"
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/XCTestExtensions/XCTestExtensions.h:
--------------------------------------------------------------------------------
1 | //
2 | // XCTestExtensions.h
3 | // XCTestExtensions
4 | //
5 | // Created by shindyu on 2017/12/22.
6 | // Copyright © 2017年 shindyu. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for XCTestExtensions.
12 | FOUNDATION_EXPORT double XCTestExtensionsVersionNumber;
13 |
14 | //! Project version string for XCTestExtensions.
15 | FOUNDATION_EXPORT const unsigned char XCTestExtensionsVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
--------------------------------------------------------------------------------
/XCTestExtensions/XCTxContext.swift:
--------------------------------------------------------------------------------
1 | //
2 | // XCTxContext.swift
3 | // XCTestExtensions
4 | //
5 | // Created by shindyu on 2018/12/12.
6 | // Copyright © 2018年 shindyu. All rights reserved.
7 | //
8 |
9 | import XCTest
10 |
11 | public protocol ContextExecutable {
12 | func XCTxContext(_ named: String, shouldSetUp: Bool, shouldTearDown: Bool, block: ()->())
13 | }
14 |
15 | extension XCTestCase: ContextExecutable {
16 | /// Execute runActivity with setup, teardown
17 | ///
18 | /// - Parameters:
19 | /// - named: Name of runActivity.
20 | /// - shouldSetUp: Flag for execute setup
21 | /// - shouldTearDown: Flag for execute tearDown
22 | /// - block: Contents of the test to be executed
23 | public func XCTxContext(_ named: String, shouldSetUp: Bool = true, shouldTearDown: Bool = true, block: ()->()) {
24 | if shouldSetUp {
25 | self.setUp()
26 | }
27 | XCTContext.runActivity(named: named, block: { _ in block() })
28 | if shouldTearDown {
29 | self.tearDown()
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/XCTestExtensionsTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/XCTestExtensionsTests/XCTAssertEventuallyTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // XCTAssertEventuallyTests.swift
3 | // XCTestExtensionsTests
4 | //
5 | // Created by shindyu on 2017/12/22.
6 | // Copyright © 2017年 shindyu. All rights reserved.
7 | //
8 | import XCTest
9 | @testable import XCTestExtensions
10 |
11 | class XCTAssertEventuallyTests: XCTestCase {
12 | func test_XCTAssertEventually() {
13 | var value = false
14 |
15 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
16 | value = true
17 | }
18 |
19 | XCTAssertEventually(value)
20 | }
21 |
22 | func test_XCTAssertEventually_valueNotChange() {
23 | XCTAssertEventually(true)
24 | }
25 |
26 | func test_XCTAssertTrueEventually() {
27 | var value = false
28 |
29 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
30 | value = true
31 | }
32 |
33 | XCTAssertTrueEventually(value)
34 | }
35 |
36 | func test_XCTAssertTrueEventually_valueNotChange() {
37 | XCTAssertTrueEventually(true)
38 | }
39 |
40 | func test_XCTAssertFalseEventually() {
41 | var value = true
42 |
43 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
44 | value = false
45 | }
46 |
47 | XCTAssertFalseEventually(value)
48 | }
49 |
50 | func test_XCTAssertFalseEventually_valueNotChange() {
51 | XCTAssertFalseEventually(false)
52 | }
53 |
54 | func test_XCTAssertEqualEventually() {
55 | let value1 = true
56 | var value2 = false
57 |
58 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
59 | value2 = true
60 | }
61 |
62 | XCTAssertEqualEventually(value1, value2)
63 | }
64 |
65 | func test_XCTAssertEqualEventually_valueNotChange() {
66 | let value1 = true
67 | let value2 = true
68 |
69 | XCTAssertEqualEventually(value1, value2)
70 | }
71 |
72 | func test_XCTAssertEqualEventually_floatingPoint() {
73 | let value1 = 1.0000000000000000001
74 | var value2 = 2.0
75 |
76 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
77 | value2 = 1.0000000000000000002
78 | }
79 |
80 | // Usually, you rarely care about floating point errors.
81 | // So I dont implement more accurate assertion.
82 | XCTAssertEqualEventually(value1, value2)
83 | }
84 |
85 | func test_XCTAssertEqualEventually_optional_1() {
86 | let value1: String? = "fujiyama"
87 | let value2: String? = "fujiyama"
88 |
89 | XCTAssertEqualEventually(value1, value2)
90 | }
91 |
92 | func test_XCTAssertEqualEventually_optional_2() {
93 | let value1: String? = nil
94 | let value2: String? = nil
95 |
96 | XCTAssertEqualEventually(value1, value2)
97 | }
98 |
99 | func test_XCTAssertEqualEventually_array() {
100 | let value1 = [1, 2]
101 | var value2 = [3, 4]
102 |
103 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
104 | value2 = [1, 2]
105 | }
106 |
107 | XCTAssertEqualEventually(value1, value2)
108 | }
109 |
110 | func test_XCTAssertEqualEventually_array_valueNotChange() {
111 | let value1 = [1, 2]
112 | let value2 = [1, 2]
113 |
114 | XCTAssertEqualEventually(value1, value2)
115 | }
116 |
117 | func test_XCTAssertEqualEventually_optionalArray() {
118 | let value1: [Int]? = [1, 2]
119 | let value2: [Int]? = [1, 2]
120 |
121 | XCTAssertEqualEventually(value1, value2)
122 | }
123 |
124 | func test_XCTAssertNilEventually_equatable() {
125 | var optional: Bool? = true
126 |
127 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
128 | optional = nil
129 | }
130 |
131 | XCTAssertNilEventually(optional)
132 | }
133 |
134 | func test_XCTAssertNilEventually_equatable_valueNotChange() {
135 | let optional: Bool? = nil
136 |
137 | XCTAssertNilEventually(optional)
138 | }
139 |
140 | func test_XCTAssertNilEventually_array() {
141 | var optional: [Int]? = [1, 2, 3]
142 |
143 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
144 | optional = nil
145 | }
146 |
147 | XCTAssertNilEventually(optional)
148 | }
149 |
150 | func test_XCTAssertNotNilEventually_equatble() {
151 | var optional: Bool? = nil
152 |
153 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
154 | optional = true
155 | }
156 |
157 | XCTAssertNotNilEventually(optional)
158 | }
159 |
160 | func test_XCTAssertNotNilEventually_equatble_valueNotChange() {
161 | let optional: Bool? = true
162 |
163 | XCTAssertNotNilEventually(optional)
164 | }
165 |
166 | func test_XCTAssertNotNilEventually_array() {
167 | var optional: [Int]? = nil
168 |
169 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
170 | optional = [1, 2, 3]
171 | }
172 |
173 | XCTAssertNotNilEventually(optional)
174 | }
175 |
176 | func test_XCTAssertNotNilEventually_array_valueNotChange() {
177 | let optional: [Int]? = [1, 2, 3]
178 |
179 | XCTAssertNotNilEventually(optional)
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/XCTestExtensionsTests/XCTxContextTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ContextTests.swift
3 | // XCTestExtensionsTests
4 | //
5 | // Created by shindyu on 2018/12/12.
6 | // Copyright © 2018年 shindyu. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import XCTestExtensions
11 |
12 | class ContextTests: XCTestCase {
13 | var contextTests_calledCount: Int!
14 |
15 | override func setUp() {
16 | super.setUp()
17 | contextTests_calledCount = 0
18 | }
19 |
20 | override func tearDown() {
21 | contextTests_calledCount -= 1
22 | super.tearDown()
23 | }
24 |
25 | private func countUp() {
26 | contextTests_calledCount += 1
27 | }
28 |
29 | func test_context_Execute_SetupAndTearDown() {
30 | XCTAssertEqual(contextTests_calledCount, 0)
31 |
32 | countUp()
33 |
34 | XCTAssertEqual(contextTests_calledCount, 1)
35 |
36 | XCTxContext("test-1") {
37 | XCTAssertEqual(contextTests_calledCount, 0)
38 |
39 | countUp()
40 | countUp()
41 |
42 | XCTAssertEqual(contextTests_calledCount, 2)
43 | }
44 |
45 | XCTAssertEqual(contextTests_calledCount, 1)
46 |
47 | XCTxContext("test-1") {
48 | XCTAssertEqual(contextTests_calledCount, 0)
49 | countUp()
50 | countUp()
51 |
52 | XCTAssertEqual(contextTests_calledCount, 2)
53 | }
54 |
55 | XCTAssertEqual(contextTests_calledCount, 1)
56 | }
57 |
58 | func test_context_shouldSetUp() {
59 | XCTAssertEqual(contextTests_calledCount, 0)
60 |
61 | countUp()
62 |
63 | XCTAssertEqual(contextTests_calledCount, 1)
64 |
65 | XCTxContext("test-1", shouldSetUp: false) {
66 | XCTAssertEqual(contextTests_calledCount, 1)
67 |
68 | countUp()
69 | countUp()
70 |
71 | XCTAssertEqual(contextTests_calledCount, 3)
72 | }
73 |
74 | XCTAssertEqual(contextTests_calledCount, 2)
75 | }
76 |
77 | func test_context_shouldTearDown() {
78 | XCTAssertEqual(contextTests_calledCount, 0)
79 |
80 | countUp()
81 |
82 | XCTAssertEqual(contextTests_calledCount, 1)
83 |
84 | XCTxContext("test-1", shouldTearDown: false) {
85 | XCTAssertEqual(contextTests_calledCount, 0)
86 |
87 | countUp()
88 | countUp()
89 |
90 | XCTAssertEqual(contextTests_calledCount, 2)
91 | }
92 |
93 | XCTAssertEqual(contextTests_calledCount, 2)
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/img/method_completion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shindyu/XCTestExtensions/8a320980a4f59c92c92687d7e7f5547b85f029aa/img/method_completion.png
--------------------------------------------------------------------------------