AliSoftware / AliSoftware/OHHTTPStubs

[Question] (Quick's) Testcases run twice whenever stubbing happens

オープン
#253 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
Waiting for input
主要言語
Objective-C
スター
5.1k
フォーク
597
PR マージ指標
30日以内にマージされた PR はありません

説明

### New Issue Checklist

- [x] I have tried with the latest version of OHHTTPStubs
- [x] I have read the [README](https://github.com/AliSoftware/OHHTTPStubs/blob/master/README.md)
- [x] I have read the [Using the right Swift Version of `OHHTTPStubs` for your project](https://github.com/AliSoftware/OHHTTPStubs#using-the-right-swift-version-of-ohhttpstubs-for-your-project) section
- [x] I have searched in the [existing issues](https://github.com/AliSoftware/OHHTTPStubs/issues?utf8=✓&q=is%3Aissue)
- [x] I have read [the OHHTTPStubs wiki](https://github.com/AliSoftware/OHHTTPStubs/wiki) to see if there wasn't a detailed page talking about my issue

### Environment

- version of OHHTTPStubs: 6.0.0
- integration method you are using:
* [x] Cocoapods
* [ ] Carthage
* [ ] submodule
* [ ] other
- version of the tool you use: 1.1.0

### Issue Description

**Test cases get executed twice whenever I'm using OHHTTPStubs to stub a response.**
I'm using Quick/Nimble together with OHHTTPStubs, which works fine. But whenever I'm stubbing a response, the test case is run twice. Now I'm fairly sure the testcases are run twice, because I see multiple prints...

##### Complete output when you encounter the issue (if any)

I.e. a test code snippet:

```swift
override func spec() {

describe("something") {
beforeEach {
print("describe before")
stub(isHost("example.com") && isPath("/")) {
// Just a response for the sake of showing this example snippet
let notConnected = NSError(domain: NSURLErrorDomain,
code: Int(CFNetworkErrors.cfurlErrorNotConnectedToInternet.rawValue),
userInfo: nil)
return OHHTTPStubsResponse(error: notConnected)
}
}
afterEach {
print("describe after")
OHHTTPStubs.removeAllStubs()
}

context("of something") {
beforeEach {
print("context before")
}
afterEach {
print("context after")
}

it("should behave like something") {
print("in the `IT`")
didFinish = false
let provider = MoyaProvider
provider.request() {
// This eventually reaches the `failure` report of the network operation (because of the No-network error response)
didFinish = true
}
expect(didFinish).toEventually(beTrue())
}
}
}

}
```
```
Test Case '-[CheckerTests something__of_something__should_behave_like_something]' started.
13:35:29.046 CheckerTests.spec():21 - describe before
13:35:29.046 CheckerTests.spec():21 - describe before
13:35:29.048 CheckerTests.spec():29 - context before
13:35:29.048 CheckerTests.spec():29 - context before
13:35:29.048 CheckerTests.spec():36 - in the `IT`
13:35:29.048 CheckerTests.spec():36 - in the `IT`
13:35:29.049 CheckerTests.spec():32 - context after
1Test Case '-[CheckerTests something__of_something__should_behave_like_something]' passed (0.024 seconds).
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。