AliSoftware / AliSoftware/OHHTTPStubs

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

Đang mở
#253 6 bình luận 0 reaction 0 người được giao Xem trên GitHub
Waiting for input
Ngôn ngữ chính
Objective-C
Star
5.1k
Fork
597
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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).
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.