Compare commits
6 Commits
master
...
feature/sw
Author | SHA1 | Date |
---|---|---|
![]() |
d69116fe88 | |
![]() |
670781ff92 | |
![]() |
227b68b55c | |
![]() |
e271f53fc4 | |
![]() |
f58cda6c03 | |
![]() |
cc18f23f80 |
|
@ -0,0 +1,22 @@
|
|||
// swift-tools-version:4.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Cuckoo",
|
||||
products: [
|
||||
.library(
|
||||
name: "Cuckoo",
|
||||
targets: ["Cuckoo"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "Cuckoo",
|
||||
dependencies: [],
|
||||
path: "Source"),
|
||||
.testTarget(
|
||||
name: "CuckooTests",
|
||||
dependencies: ["Cuckoo"],
|
||||
path: "Tests"),
|
||||
]
|
||||
)
|
59
README.md
59
README.md
|
@ -87,8 +87,63 @@ Input files can be also specified directly in `Run script` in `Input Files` form
|
|||
Note: All paths in the Run script must be absolute. Variable `PROJECT_DIR` automatically points to your project directory.
|
||||
**Remember to include paths to inherited Classes and Protocols for mocking/stubbing parent and grandparents.**
|
||||
|
||||
#### Swift Package Manager
|
||||
|
||||
To use Cuckoo with Apple's Swift package manager, add the following as a dependency to your `Package.swift`:
|
||||
|
||||
```swift
|
||||
.package(url: "https://github.com/Brightify/Cuckoo.git", .upToNextMajor(from: "1.3.0"))
|
||||
```
|
||||
|
||||
after that add `"Cuckoo"` as a dependency of the test target.
|
||||
|
||||
If you're unsure, take a look at this example `PackageDescription`:
|
||||
|
||||
```swift
|
||||
// swift-tools-version:4.0
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Friendlyst",
|
||||
products: [
|
||||
.library(
|
||||
name: "Friendlyst",
|
||||
targets: ["Friendlyst"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/Brightify/Cuckoo.git", .upToNextMajor(from: "1.3.0"))
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "Friendlyst",
|
||||
dependencies: [],
|
||||
path: "Source"),
|
||||
.testTarget(
|
||||
name: "FriendlystTests",
|
||||
dependencies: ["Cuckoo"],
|
||||
path: "Tests"),
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
Cuckoo relies on a script that is currently not downloadable using SwiftPM. However, for convenience, you can copy this line into the terminal to download the latest `run` script. Unfortunately if there are changes in the `run` script, you'll need to execute this line again.
|
||||
```Bash
|
||||
curl https://raw.githubusercontent.com/Brightify/Cuckoo/master/run > run && chmod +x run
|
||||
```
|
||||
|
||||
When you're all set, use the same `Run script` phase as above and replace
|
||||
```Bash
|
||||
"${PODS_ROOT}/Cuckoo/run"
|
||||
```
|
||||
with
|
||||
```Bash
|
||||
"${PROJECT_DIR}/run" --download
|
||||
```
|
||||
|
||||
The `--download` option is necessary because the `Generator` sources are not cloned in your project (they're in DerivedData, out of reach). You can add a version (e.g. 1.3.0) after it to get a specific version of the `cuckoo_generator`. Use `--clean` as well to replace the current `cuckoo_generator` if you're changing versions.
|
||||
|
||||
#### Carthage
|
||||
To use Cuckoo with [Carthage](https://github.com/Carthage/Carthage) add in your Cartfile this line:
|
||||
To use Cuckoo with [Carthage](https://github.com/Carthage/Carthage) add this line to your Cartfile:
|
||||
```
|
||||
github "Brightify/Cuckoo"
|
||||
```
|
||||
|
@ -102,7 +157,7 @@ with
|
|||
"Carthage/Checkouts/Cuckoo/run"
|
||||
```
|
||||
|
||||
Also don't forget to add the Framework into your project's test target.
|
||||
Don't forget to add the Framework into your project.
|
||||
|
||||
### 2. Usage
|
||||
Usage of Cuckoo is similar to [Mockito](http://mockito.org/) and [Hamcrest](http://hamcrest.org/). However, there are some differences and limitations caused by generating the mocks and Swift language itself. List of all the supported features can be found below. You can find complete examples in [tests](Tests).
|
||||
|
|
7
run
7
run
|
@ -11,7 +11,7 @@ function perform_curl {
|
|||
fi
|
||||
|
||||
DOWNLOAD_URL=$(curl "${CURL_OPTIONS[@]}" "$1" | grep -oe '"browser_download_url":\s*"[^" ]*"' | grep -oe 'http[^" ]*' | grep "$FILE_NAME" | head -1)
|
||||
|
||||
|
||||
if [[ -z "$DOWNLOAD_URL" ]]; then
|
||||
echo "Error: Failed to fetch download URL for the Cuckoo Generator."
|
||||
exit 1
|
||||
|
@ -74,13 +74,13 @@ case $1 in
|
|||
fi
|
||||
shift
|
||||
;;
|
||||
|
||||
|
||||
-c|--clean)
|
||||
CLEAN=1
|
||||
echo "Performing clean build."
|
||||
shift
|
||||
;;
|
||||
|
||||
|
||||
*)
|
||||
POSITIONAL+=("$1") # save it in an array for later
|
||||
shift
|
||||
|
@ -110,4 +110,3 @@ do
|
|||
done
|
||||
|
||||
echo $INPUT_FILES | xargs "$FILE_PATH"
|
||||
|
||||
|
|
Loading…
Reference in New Issue