AliSoftware / AliSoftware/OHHTTPStubs

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

Aberta
#253 6 comentários 0 reações 0 responsáveis Ver no GitHub
Waiting for input
Linguagem predominante
Objective-C
Estrelas
5.1k
Forks
597
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.