Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registrating stubs per Nocilla instance. #119

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pstasiak
Copy link

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

@luisobo
Copy link
Owner

luisobo 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
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?

@luisobo
Copy link
Owner

luisobo 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
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