Skip to content

Commit a5f1d0c

Browse files
committed
Documentation and preparation for v4.0.0
1 parent 78e6f66 commit a5f1d0c

File tree

142 files changed

+10870
-6726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+10870
-6726
lines changed

.jazzy.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ custom_categories:
1717
- Mockfile
1818
- Command Line Interface
1919
- Supported features
20+
- Prototyping
2021

2122
- name: Additional Guides
2223
children:
@@ -62,11 +63,6 @@ custom_categories:
6263
- XCTAssertThrowsError(_:error:_:file:line:)
6364
- MockyAssertion
6465

65-
- name: Deprecated
66-
children:
67-
- VerifyProperty(_:_:file:line:)
68-
- VerifyProperty(_:_:_:file:line:)
69-
7066
- name: Internal
7167
children:
7268
- SwiftyMockyTestObserver

Mintfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
MakeAWishFoundation/SwiftyMocky-CLI@4.0.0-pre
1+
MakeAWishFoundation/SwiftyMocky-CLI@4.0.0

README.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Check out [guides][link-guides-contents], or full [documentation][link-docs]
1717
## Table of contents
1818

1919
1. [Overview](#overview)
20-
1. [Current version](#current-version)
20+
1. [Current Version](#current-version)
2121
1. [Getting started:](#getting-started)
2222
1. [Installing SwiftyMocky CLI](#installation)
2323
1. [Integrating SwiftyMocky runtime into test target](#integration)
@@ -54,24 +54,28 @@ The idea of **SwiftyMocky** is to automatically mock Swift protocols. The main f
5454

5555
<a name="current-version"></a>
5656

57-
## Current version
57+
## **Important!!!** Version 4.x.x
5858

59-
We consider current version as stable. We are moving toward using the new [Mockfile][link-guides-mockfile] but the previous configuration format would be still supported, until SwiftyMocky 4.0. Library works with Swift **4.1, 4.2, 5.0, 5.1.2** and Sourcery 0.17.0.
59+
Current version has several significant changes. It removes deprecated methods (which might be breaking) and moves CLI to the new [repository](https://github.com/MakeAWishFoundation/SwiftyMockyCLI).
6060

61-
While it is technically possible to integrate SwiftyMocky on Linux targets, there is no Mock generation feature there yet. You can use SwiftyMokcy runtime via SwiftPM though, as long as your are fine with generating mocks on mac machine.
61+
**SwiftyPrototype** was also extracted to separate library. There are no more compilation flags, so if you were relying on **SwiftyMocky** with `-DMockyCustom`, you will have to switch to `SwiftyPrototype`.
6262

63-
<a name="getting-started"></a>
63+
We consider current version as stable. We are moving toward using the new [Mockfile][link-guides-mockfile] but the previous configuration format would be still supported. Library works with Swift **4.1, 4.2, 5.0, 5.1.2** and Sourcery 0.17-0.18.
64+
65+
While it is technically possible to integrate SwiftyMocky on Linux targets, there is no Mock generation feature there yet. You can use SwiftyMokcy runtime via SwiftPM though, as long as your are fine with generating mocks on mac machine.
6466

6567
## Migration from 3.2.0 and below
6668

6769
The migration is not required, you can keep using **SwiftyMocky** as you did before. The [Legacy setup](https://github.com/MakeAWishFoundation/SwiftyMocky/blob/master/guides/Legacy.md) is described in [guides section](https://github.com/MakeAWishFoundation/SwiftyMocky/blob/master/guides/Contents.md).
6870

69-
Still, we would encourage to try new **CLI** and share a feedback. We believe it will make using and setting up **SwiftyMocky** way easier. If you have an existing setup, try:
71+
Still, we would encourage to try new **CLI** and share a feedback. We believe it will make using and setting up **SwiftyMocky** way easier. If you have an existing setup, install CLI as per this [guide](https://github.com/MakeAWishFoundation/SwiftyMocky/blob/master/guides/Installation.md) and try:
7072

7173
```bash
7274
> swiftymocky migrate
7375
```
7476

77+
<a name="getting-started"></a>
78+
7579
## Getting started
7680

7781
To start working with **SwiftyMocky** you need to:
@@ -88,15 +92,19 @@ To start working with **SwiftyMocky** you need to:
8892

8993
```bash
9094
> brew install mint
91-
> mint install MakeAWishFoundation/SwiftyMocky
95+
> mint install MakeAWishFoundation/SwiftyMocky-CLI
9296
```
9397

9498
**[Marathon 🏃](https://github.com/JohnSundell/Marathon)**:
9599

96100
```bash
97-
> marathon install MakeAWishFoundation/SwiftyMocky
101+
> marathon install MakeAWishFoundation/SwiftyMocky-CLI
98102
```
99103

104+
**Make**:
105+
106+
Clone from https://github.com/MakeAWishFoundation/SwiftyMockyCLI and run `make` in the root directory.
107+
100108
<a name="integration"></a>
101109

102110
### 2. Integrating SwiftyMocky runtime into test target:
@@ -180,16 +188,6 @@ protocol ToBeMocked {
180188

181189
Every protocol in source directories, having this annotation, will be added to `Mock.generated.swift`
182190

183-
@objc protocols are also supported, but needs to be explicitly marked with ObjcProtocol annotation:
184-
185-
```swift
186-
//sourcery: AutoMockable
187-
//sourcery: ObjcProtocol
188-
@objc protocol NonSwiftProtocol {
189-
// ...
190-
}
191-
```
192-
193191
<a name="given"></a>
194192

195193
## 2. Stubbing return values for mock methods - **Given**
@@ -315,7 +313,7 @@ For more examples, check out our example project, or examples section in [guides
315313

316314
To run the example project, clone the repo, and run `pod install` from the Example directory first.
317315

318-
To trigger mocks generation, run `rake mock` from root directory.
316+
To trigger mocks generation, run `rake mock` or `swiftymocky generate` from root directory (if you installed CLI).
319317

320318
<a name="roadmap"></a>
321319

Sources/Shared/Count.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public enum Count: ExpressibleByIntegerLiteral {
5050
}
5151

5252
// MARK: - CustomStringConvertible
53+
5354
extension Count: CustomStringConvertible {
5455
/// Human readable description
5556
public var description: String {
@@ -79,6 +80,7 @@ extension Count: CustomStringConvertible {
7980
}
8081

8182
// MARK: - Countable
83+
8284
extension Count: Countable {
8385

8486
/// Returns whether given count matches countable case.

Sources/Shared/Mock+Assertions.swift

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ public func Verify<T: Mock>(_ object: T, _ method: T.Verify, file: StaticString
1313
object.verify(method, count: .moreOrEqual(to: 1), file: file, line: line)
1414
}
1515

16-
/// Verify that given property getter or setter was called on mock object **at least once**.
17-
///
18-
/// - Parameters:
19-
/// - object: Mock instance
20-
/// - property: Property name, get or set with wrapped newValue (`Parameter`)
21-
/// - file: for XCTest print purposes
22-
/// - line: for XCTest print purposes
23-
@available(*, deprecated, message: "Use Verify instead!")
24-
public func VerifyProperty<T: Mock>(_ object: T, _ property: T.Verify, file: StaticString = #file, line: UInt = #line) {
25-
object.verify(property, count: .moreOrEqual(to: 1), file: file, line: line)
26-
}
27-
2816
// MARK: - At least once static member called
2917

3018
/// Verify that given static method was called on mock type **at least once**.
@@ -38,18 +26,6 @@ public func Verify<T: StaticMock>(_ type: T.Type, _ method: T.StaticVerify, file
3826
T.verify(method, count: .moreOrEqual(to: 1), file: file, line: line)
3927
}
4028

41-
/// Verify that given static property getter or setter was called on mock object **at least once**.
42-
///
43-
/// - Parameters:
44-
/// - object: Mock type
45-
/// - property: Property name, get or set with wrapped newValue (`Parameter`)
46-
/// - file: for XCTest print purposes
47-
/// - line: for XCTest print purposes
48-
@available(*, deprecated, message: "Use Verify instead!")
49-
public func VerifyProperty<T: StaticMock>(_ object: T.Type, _ property: T.StaticVerify, file: StaticString = #file, line: UInt = #line) {
50-
T.verify(property, count: .moreOrEqual(to: 1), file: file, line: line)
51-
}
52-
5329
// MARK: - Instance member called with explicit count
5430

5531
/// Verify that given method was called on mock object **exact number of times**.
@@ -64,19 +40,6 @@ public func Verify<T: Mock>(_ object: T, _ count: Count, _ method: T.Verify, fil
6440
object.verify(method, count: count, file: file, line: line)
6541
}
6642

67-
/// Verify that given property get / set was called on mock object **exact number of times**.
68-
///
69-
/// - Parameters:
70-
/// - object: Mock instance
71-
/// - count: Number of invocations
72-
/// - method: Property name, get or set with wrapped newValue (`Parameter`)
73-
/// - file: for XCTest print purposes
74-
/// - line: for XCTest print purposes
75-
@available(*, deprecated, message: "Use Verify instead!")
76-
public func VerifyProperty<T: Mock>(_ object: T, _ count: Count, _ property: T.Verify, file: StaticString = #file, line: UInt = #line) {
77-
object.verify(property, count: count, file: file, line: line)
78-
}
79-
8043
// MARK: - Static member called with explicit count
8144

8245
/// Verify that given static method was called on mock type **exact number of times**.
@@ -91,19 +54,6 @@ public func Verify<T: StaticMock>(_ type: T.Type, _ count: Count, _ method: T.St
9154
T.verify(method, count: count, file: file, line: line)
9255
}
9356

94-
/// Verify that given static property get / set was called on mock type **exact number of times**.
95-
///
96-
/// - Parameters:
97-
/// - object: Mock type
98-
/// - count: Number of invocations
99-
/// - method: Static property name, get or set with wrapped newValue (`Parameter`)
100-
/// - file: for XCTest print purposes
101-
/// - line: for XCTest print purposes
102-
@available(*, deprecated, message: "Use Verify instead!")
103-
public func VerifyProperty<T: StaticMock>(_ type: T.Type, _ count: Count, _ property: T.StaticVerify, file: StaticString = #file, line: UInt = #line) {
104-
T.verify(property, count: count, file: file, line: line)
105-
}
106-
10757
// MARK: - Given
10858

10959
/// Setup return value for method stubs in mock instance. When this method will be called on mock, it

Sources/SwiftyMocky/Count.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public enum Count: ExpressibleByIntegerLiteral {
5050
}
5151

5252
// MARK: - CustomStringConvertible
53+
5354
extension Count: CustomStringConvertible {
5455
/// Human readable description
5556
public var description: String {
@@ -79,6 +80,7 @@ extension Count: CustomStringConvertible {
7980
}
8081

8182
// MARK: - Countable
83+
8284
extension Count: Countable {
8385

8486
/// Returns whether given count matches countable case.

Sources/SwiftyMocky/Mock+Assertions.swift

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ public func Verify<T: Mock>(_ object: T, _ method: T.Verify, file: StaticString
1313
object.verify(method, count: .moreOrEqual(to: 1), file: file, line: line)
1414
}
1515

16-
/// Verify that given property getter or setter was called on mock object **at least once**.
17-
///
18-
/// - Parameters:
19-
/// - object: Mock instance
20-
/// - property: Property name, get or set with wrapped newValue (`Parameter`)
21-
/// - file: for XCTest print purposes
22-
/// - line: for XCTest print purposes
23-
@available(*, deprecated, message: "Use Verify instead!")
24-
public func VerifyProperty<T: Mock>(_ object: T, _ property: T.Verify, file: StaticString = #file, line: UInt = #line) {
25-
object.verify(property, count: .moreOrEqual(to: 1), file: file, line: line)
26-
}
27-
2816
// MARK: - At least once static member called
2917

3018
/// Verify that given static method was called on mock type **at least once**.
@@ -38,18 +26,6 @@ public func Verify<T: StaticMock>(_ type: T.Type, _ method: T.StaticVerify, file
3826
T.verify(method, count: .moreOrEqual(to: 1), file: file, line: line)
3927
}
4028

41-
/// Verify that given static property getter or setter was called on mock object **at least once**.
42-
///
43-
/// - Parameters:
44-
/// - object: Mock type
45-
/// - property: Property name, get or set with wrapped newValue (`Parameter`)
46-
/// - file: for XCTest print purposes
47-
/// - line: for XCTest print purposes
48-
@available(*, deprecated, message: "Use Verify instead!")
49-
public func VerifyProperty<T: StaticMock>(_ object: T.Type, _ property: T.StaticVerify, file: StaticString = #file, line: UInt = #line) {
50-
T.verify(property, count: .moreOrEqual(to: 1), file: file, line: line)
51-
}
52-
5329
// MARK: - Instance member called with explicit count
5430

5531
/// Verify that given method was called on mock object **exact number of times**.
@@ -64,19 +40,6 @@ public func Verify<T: Mock>(_ object: T, _ count: Count, _ method: T.Verify, fil
6440
object.verify(method, count: count, file: file, line: line)
6541
}
6642

67-
/// Verify that given property get / set was called on mock object **exact number of times**.
68-
///
69-
/// - Parameters:
70-
/// - object: Mock instance
71-
/// - count: Number of invocations
72-
/// - method: Property name, get or set with wrapped newValue (`Parameter`)
73-
/// - file: for XCTest print purposes
74-
/// - line: for XCTest print purposes
75-
@available(*, deprecated, message: "Use Verify instead!")
76-
public func VerifyProperty<T: Mock>(_ object: T, _ count: Count, _ property: T.Verify, file: StaticString = #file, line: UInt = #line) {
77-
object.verify(property, count: count, file: file, line: line)
78-
}
79-
8043
// MARK: - Static member called with explicit count
8144

8245
/// Verify that given static method was called on mock type **exact number of times**.
@@ -91,19 +54,6 @@ public func Verify<T: StaticMock>(_ type: T.Type, _ count: Count, _ method: T.St
9154
T.verify(method, count: count, file: file, line: line)
9255
}
9356

94-
/// Verify that given static property get / set was called on mock type **exact number of times**.
95-
///
96-
/// - Parameters:
97-
/// - object: Mock type
98-
/// - count: Number of invocations
99-
/// - method: Static property name, get or set with wrapped newValue (`Parameter`)
100-
/// - file: for XCTest print purposes
101-
/// - line: for XCTest print purposes
102-
@available(*, deprecated, message: "Use Verify instead!")
103-
public func VerifyProperty<T: StaticMock>(_ type: T.Type, _ count: Count, _ property: T.StaticVerify, file: StaticString = #file, line: UInt = #line) {
104-
T.verify(property, count: count, file: file, line: line)
105-
}
106-
10757
// MARK: - Given
10858

10959
/// Setup return value for method stubs in mock instance. When this method will be called on mock, it

Sources/SwiftyPrototype/Count.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public enum Count: ExpressibleByIntegerLiteral {
5050
}
5151

5252
// MARK: - CustomStringConvertible
53+
5354
extension Count: CustomStringConvertible {
5455
/// Human readable description
5556
public var description: String {
@@ -79,6 +80,7 @@ extension Count: CustomStringConvertible {
7980
}
8081

8182
// MARK: - Countable
83+
8284
extension Count: Countable {
8385

8486
/// Returns whether given count matches countable case.

Sources/SwiftyPrototype/Mock+Assertions.swift

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ public func Verify<T: Mock>(_ object: T, _ method: T.Verify, file: StaticString
1313
object.verify(method, count: .moreOrEqual(to: 1), file: file, line: line)
1414
}
1515

16-
/// Verify that given property getter or setter was called on mock object **at least once**.
17-
///
18-
/// - Parameters:
19-
/// - object: Mock instance
20-
/// - property: Property name, get or set with wrapped newValue (`Parameter`)
21-
/// - file: for XCTest print purposes
22-
/// - line: for XCTest print purposes
23-
@available(*, deprecated, message: "Use Verify instead!")
24-
public func VerifyProperty<T: Mock>(_ object: T, _ property: T.Verify, file: StaticString = #file, line: UInt = #line) {
25-
object.verify(property, count: .moreOrEqual(to: 1), file: file, line: line)
26-
}
27-
2816
// MARK: - At least once static member called
2917

3018
/// Verify that given static method was called on mock type **at least once**.
@@ -38,18 +26,6 @@ public func Verify<T: StaticMock>(_ type: T.Type, _ method: T.StaticVerify, file
3826
T.verify(method, count: .moreOrEqual(to: 1), file: file, line: line)
3927
}
4028

41-
/// Verify that given static property getter or setter was called on mock object **at least once**.
42-
///
43-
/// - Parameters:
44-
/// - object: Mock type
45-
/// - property: Property name, get or set with wrapped newValue (`Parameter`)
46-
/// - file: for XCTest print purposes
47-
/// - line: for XCTest print purposes
48-
@available(*, deprecated, message: "Use Verify instead!")
49-
public func VerifyProperty<T: StaticMock>(_ object: T.Type, _ property: T.StaticVerify, file: StaticString = #file, line: UInt = #line) {
50-
T.verify(property, count: .moreOrEqual(to: 1), file: file, line: line)
51-
}
52-
5329
// MARK: - Instance member called with explicit count
5430

5531
/// Verify that given method was called on mock object **exact number of times**.
@@ -64,19 +40,6 @@ public func Verify<T: Mock>(_ object: T, _ count: Count, _ method: T.Verify, fil
6440
object.verify(method, count: count, file: file, line: line)
6541
}
6642

67-
/// Verify that given property get / set was called on mock object **exact number of times**.
68-
///
69-
/// - Parameters:
70-
/// - object: Mock instance
71-
/// - count: Number of invocations
72-
/// - method: Property name, get or set with wrapped newValue (`Parameter`)
73-
/// - file: for XCTest print purposes
74-
/// - line: for XCTest print purposes
75-
@available(*, deprecated, message: "Use Verify instead!")
76-
public func VerifyProperty<T: Mock>(_ object: T, _ count: Count, _ property: T.Verify, file: StaticString = #file, line: UInt = #line) {
77-
object.verify(property, count: count, file: file, line: line)
78-
}
79-
8043
// MARK: - Static member called with explicit count
8144

8245
/// Verify that given static method was called on mock type **exact number of times**.
@@ -91,19 +54,6 @@ public func Verify<T: StaticMock>(_ type: T.Type, _ count: Count, _ method: T.St
9154
T.verify(method, count: count, file: file, line: line)
9255
}
9356

94-
/// Verify that given static property get / set was called on mock type **exact number of times**.
95-
///
96-
/// - Parameters:
97-
/// - object: Mock type
98-
/// - count: Number of invocations
99-
/// - method: Static property name, get or set with wrapped newValue (`Parameter`)
100-
/// - file: for XCTest print purposes
101-
/// - line: for XCTest print purposes
102-
@available(*, deprecated, message: "Use Verify instead!")
103-
public func VerifyProperty<T: StaticMock>(_ type: T.Type, _ count: Count, _ property: T.StaticVerify, file: StaticString = #file, line: UInt = #line) {
104-
T.verify(property, count: count, file: file, line: line)
105-
}
106-
10757
// MARK: - Given
10858

10959
/// Setup return value for method stubs in mock instance. When this method will be called on mock, it

0 commit comments

Comments
 (0)