Registrating stubs per Nocilla instance.#119
Registrating stubs per Nocilla instance.#119pstasiak wants to merge 4 commits intolausobo:masterfrom
Conversation
|
@pstasiak I don't understand what this is for. Would you mind to provide some use cases? Also, the PR has some problems. For example, the documentation is not updated and there are no tests for any of the changes. But I wouldn't worry about that until the purpose of this change is clear. |
|
I created this fork to fix issue with not reproducable tests' results in one of my project. If I run test one by one, everything was fine, so I started looking how their interfere. I observed that sometimes nocilla was not returning responses I stubbed in a particular test, but one from other test. Problem happen when there are multiple tests with stubbed identical request but different responses. If tests are running simultaneously, response from last stub will be return in both tests. My fork gives ability to create separate Nocilla instance per test, and do not mixing those responses. Is there any other way to avoid such problem? |
|
This should not be the case, Nocilla should support that use case just fine as long as both tests do not run concurrently, which is something not supported by the existing test frameworks anyway. There may be a bug in Nocilla, but first I'd like to see if you are running into the same issue that most people: You need to ensure that each test finishes only after the request that you are testing has finished. In other words, you need to use an async matcher (depending on the test framework you are using) to make sure that your test waits for the response before existing the test and calling -[LSNocilla clearStubs] or -[LSNocilla stop]. Can you share one of the the classes that is giving you trouble? |
|
So that is my case - my tests where fired concurrently when running on iOS 8 simulator (on iOS7 everything was ok). I will paste code later. I'm using Expecta async matchers. |
To be able to run simultaneously multiple tests with same requests stubs.