Skip to content

Commit

Permalink
Merge Conbini & ConbiniForTesting
Browse files Browse the repository at this point in the history
  • Loading branch information
dehesa committed Sep 19, 2020
1 parent 6b87d15 commit a62520b
Show file tree
Hide file tree
Showing 43 changed files with 67 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Steps to reproduce the behavior:
A clear and concise description of what you expected to happen.

## System
- OS: [e.g. macOS 10.15.4, iOS 13.4]
- Conbini: [e.g. 0.5.2]
- OS: [e.g. macOS 11, iOS 14]
- Conbini: [e.g. 0.7.0]
You can check this in your SPM `Package.swift` file (or `Package.resolved` file). Alternatively, go to Xcode's Source Control Navigator (`⌘+2`) and click on `Conbini`.

## Additional context
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Add any other context about the question here.

## System
Delete section if not applicable
- OS: [e.g. macOS 10.15.4, iOS 13.4]
- Conbini: [e.g. 0.5.2]
- OS: [e.g. macOS 11, iOS 14]
- Conbini: [e.g. 0.7.0]
You can check this in your SPM `Package.swift` file (or `Package.resolved` file). Alternatively, go to Xcode's Source Control Navigator (`⌘+2`) and click on `Conbini`.
7 changes: 2 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ let package = Package(
],
products: [
.library(name: "Conbini", targets: ["Conbini"]),
.library(name: "ConbiniForTesting", targets: ["ConbiniForTesting"])
],
dependencies: [],
targets: [
.target(name: "Conbini", dependencies: [], path: "sources/conbini"),
.target(name: "ConbiniForTesting", dependencies: [], path: "sources/testing"),
.testTarget(name: "ConbiniTests", dependencies: ["Conbini"], path: "tests/conbiniTests"),
.testTarget(name: "ConbiniForTestingTests", dependencies: ["ConbiniForTesting"], path: "tests/testingTests")
.target(name: "Conbini", dependencies: [], path: "sources"),
.testTarget(name: "ConbiniTests", dependencies: ["Conbini"], path: "tests"),
]
)
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import PackageDescription
let package = Package(
/* Your package name, supported platforms, and generated products go here */
dependencies: [
.package(url: "https://github.com/dehesa/Conbini.git", from: "0.6.0")
.package(url: "https://github.com/dehesa/Conbini.git", from: "0.7.0")
],
targets: [
.target(name: /* Your target name here */, dependencies: ["Conbini"])
Expand All @@ -40,11 +40,6 @@ let package = Package(
import Conbini
```

The testing conveniences depend on [XCTest](https://developer.apple.com/documentation/xctest), which is not available on regular execution. That is why Conbini is offered in two flavors:

- `import Conbini` includes all code excepts the testing conveniences.
- `import ConbiniForTesting` includes the testing functionality only.

</p></details>
</ul>

Expand Down Expand Up @@ -376,6 +371,32 @@ let emittedValue = publisherChain.expectsOne(timeout: 0.8, on: test)
</p></details>
</ul>

`XCTestCase` has been _extended_ to support the following functionality.

<ul>
<details><summary><code>wait(seconds:)</code></summary><p>

Locks the receiving test for `interval` amount of seconds.

```swift
final class CustomTests: XCTestCase {
func testSomething() {
let subject = PassthroughSubject<Int,Never>()
let cancellable = subject.sink { print($0) }

let queue = DispatchQueue.main
queue.asyncAfter(.now() + 1) { subject.send(1) }
queue.asyncAfter(.now() + 2) { subject.send(2) }

self.wait(seconds: 3)
cancellable.cancel()
}
}
```

</p></details>
</ul>

# References

- Apple's [Combine documentation](https://developer.apple.com/documentation/combine).
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if canImport(XCTest)
#if !os(watchOS) && canImport(XCTest)
import XCTest
import Combine

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if canImport(XCTest)
#if !os(watchOS) && canImport(XCTest)
import XCTest
import Combine
import Foundation
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -53,3 +54,4 @@ extension AssignOpTests {
XCTAssert(objC.value == data.last!)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -100,3 +101,4 @@ extension DelayedRetryOpTests {
cancellable.cancel()
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -131,3 +132,4 @@ extension HandleEndOpTests {
cancellable.cancel()
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -73,3 +74,4 @@ extension ResultOpTests {
self.wait(for: [expA], timeout: 0.2)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -54,3 +55,4 @@ extension ThenOpTests {
cancellable.cancel()
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -89,3 +90,4 @@ extension DeferredCompleteTests {
cancellable.cancel()
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -79,3 +80,4 @@ extension DeferredFutureTests {
cancellable.cancel()
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -86,3 +87,4 @@ extension DeferredPassthroughTests {
XCTAssertEqual(.init(values.prefix(upTo: 2)), receivedValues)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -52,3 +53,4 @@ extension DeferredResultTests {
self.wait(for: [exp], timeout: 0.2)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -82,3 +83,4 @@ extension DeferredTryCompleteTests {
self.wait(for: [exp], timeout: 0.2)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -50,3 +51,4 @@ extension DeferredTryValueTests {
self.wait(for: [exp], timeout: 0.2)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -36,3 +37,4 @@ extension DeferredValueTests {
self.wait(for: [exp], timeout: 0.2)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if !os(watchOS)
import XCTest
import Conbini
import ConbiniForTesting
import Combine

/// Tests the correct behavior of the *expectation* conveniences.
Expand Down Expand Up @@ -82,3 +82,4 @@ extension ExpectationsTests {
XCTAssertEqual(.init(values[0..<2]), subjectEmitted)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -85,3 +86,4 @@ extension FixedSinkTests {
subscriber.cancel()
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -64,3 +65,4 @@ extension GraduatedSinkTests {
subscriber.cancel()
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import XCTest
import Conbini
import Combine
Expand Down Expand Up @@ -69,3 +70,4 @@ extension BufferTests {
XCTAssertEqual(input.map { $0 * 4 }, output)
}
}
#endif

0 comments on commit a62520b

Please sign in to comment.