Skip to content

Registrating stubs per Nocilla instance.#119

Open
pstasiak wants to merge 4 commits intolausobo:masterfrom
pstasiak:master
Open

Registrating stubs per Nocilla instance.#119
pstasiak wants to merge 4 commits intolausobo:masterfrom
pstasiak:master

Conversation

@pstasiak
Copy link
Copy Markdown

To be able to run simultaneously multiple tests with same requests stubs.

@lausobo
Copy link
Copy Markdown
Owner

lausobo commented Jun 19, 2015

@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.

@pstasiak
Copy link
Copy Markdown
Author

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?

@lausobo
Copy link
Copy Markdown
Owner

lausobo commented Jun 19, 2015

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?

@pstasiak
Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants