Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use built-in swift-testing for Xcode 16 #49

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ let package = Package(

if isDevelop {
package.dependencies.append(contentsOf: [
.package(url: "https://github.com/apple/swift-testing", exact: "0.3.0"),
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.10.0"),
])
if isObjcAvailable {
Expand All @@ -53,7 +52,6 @@ if isDevelop {
name: "StubNetworkKitTests",
dependencies: [
"StubNetworkKit",
.product(name: "Testing", package: "swift-testing"),
"Alamofire",
],
resources: [.copy("_Fixtures")]
Expand All @@ -63,6 +61,14 @@ if isDevelop {
"APIKit",
])
}
#if compiler(<6.0)
package.dependencies.append(contentsOf: [
.package(url: "https://github.com/apple/swift-testing", exact: "0.3.0"),
])
testTarget.dependencies.append(contentsOf: [
.product(name: "Testing", package: "swift-testing"),
])
#endif
package.targets.append(testTarget)

if isObjcAvailable {
Expand Down
6 changes: 6 additions & 0 deletions Sources/StubNetworkKit/StubURLProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ final class StubURLProtocol: URLProtocol {
private(set) static var stubs: [Stub] = []
#endif

private static let lock = NSLock()

override static func canInit(with request: URLRequest) -> Bool {
true
}
Expand Down Expand Up @@ -58,10 +60,14 @@ final class StubURLProtocol: URLProtocol {

extension StubURLProtocol {
static func register(_ stub: Stub) {
lock.lock()
defer { lock.unlock() }
stubs.append(stub)
}

static func reset() {
lock.lock()
defer { lock.unlock() }
stubs = []
}
}
Expand Down
1 change: 0 additions & 1 deletion TestPlan.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"defaultOptions" : {
"maximumTestRepetitions" : 3,
"nsZombieEnabled" : true,
"repeatInNewRunnerProcess" : true,
"testRepetitionMode" : "retryOnFailure",
"testTimeoutsEnabled" : true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import FoundationNetworking
import Testing
import StubNetworkKit

#if compiler(<6.0)
@Suite
#else
@Suite(.serialized)
#endif
final class StubNetworkKitTests_SwiftTesting {
init() {
StubNetworking.option(printDebugLog: true,
Expand Down
Loading