8000 Merge SpecRunner implementation into single file by ikesyo · Pull Request #881 · Quick/Quick · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Merge SpecRunner implementation into single file #881

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

Merged
merged 1 commit into from
May 2, 2019
Merged
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
31 changes: 0 additions & 31 deletions Tests/QuickTests/QuickTestHelpers/SpecRunner.swift

This file was deleted.

4 changes: 0 additions & 4 deletions Tests/QuickTests/QuickTestHelpers/TestRun.swift

This file was deleted.

44 changes: 39 additions & 5 deletions Tests/QuickTests/QuickTests/Helpers/QuickSpecRunner.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#if canImport(Darwin) && !SWIFT_PACKAGE
import Foundation
import XCTest
@testable import Quick
import Nimble

#if canImport(Darwin) && !SWIFT_PACKAGE
typealias TestRun = XCTestRun
#else
struct TestRun {
var executionCount: UInt
var hasSucceeded: Bool
}
#endif

/**
Runs an XCTestSuite instance containing only the given QuickSpec subclass.
Expand All @@ -14,7 +23,7 @@ import XCTest
@return An XCTestRun instance that contains information such as the number of failures, etc.
*/
@discardableResult
func qck_runSpec(_ specClass: QuickSpec.Type) -> XCTestRun? {
func qck_runSpec(_ specClass: QuickSpec.Type) -> TestRun? {
return qck_runSpecs([specClass])
}

Expand All @@ -26,7 +35,8 @@ func qck_runSpec(_ specClass: QuickSpec.Type) -> XCTestRun? {
@return An XCTestRun instance that contains information such as the number of failures, etc.
*/
@discardableResult
func qck_runSpecs(_ specClasses: [QuickSpec.Type]) -> XCTestRun? {
func qck_runSpecs(_ specClasses: [QuickSpec.Type]) -> TestRun? {
#if canImport(Darwin) && !SWIFT_PACKAGE
return World.anotherWorld { world -> XCTestRun? in
QuickConfiguration.configureSubclassesIfNeeded(world: world)

Expand All @@ -46,16 +56,40 @@ func qck_runSpecs(_ specClasses: [QuickSpec.Type]) -> XCTestRun? {
return result

}
#else
let world = Quick.World.sharedWorld
world.isRunningAdditionalSuites = true
defer { world.isRunningAdditionalSuites = false }

var executionCount: UInt = 0
var hadUnexpectedFailure = false

let fails = gatherFailingExpectations(silently: true) {
for specClass in specClasses {
for (_, test) in specClass.allTests {
do {
try test(specClass.init())()
} catch {
hadUnexpectedFailure = true
}
executionCount += 1
}
}
}

return TestRun(executionCount: executionCount, hasSucceeded: fails.isEmpty && !hadUnexpectedFailure)
#endif
}

#if canImport(Darwin) && !SWIFT_PACKAGE
@objc(QCKSpecRunner)
@objcMembers
class QuickSpecRunner: NSObject {
static func runSpec(_ specClass: QuickSpec.Type) -> XCTestRun? {
static func runSpec(_ specClass: QuickSpec.Type) -> TestRun? {
return qck_runSpec(specClass)
}

static func runSpecs(_ specClasses: [QuickSpec.Type]) -> XCTestRun? {
static func runSpecs(_ specClasses: [QuickSpec.Type]) -> TestRun? {
return qck_runSpecs(specClasses)
}
}
Expand Down
0