Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8303235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:28:35+00:00 2026-06-08T17:28:35+00:00

I use unit test. Also I use asynchronous requests for retrive data from server.

  • 0

I use unit test. Also I use asynchronous requests for retrive data from server. My questions is how can I test this request, cause now my tests work without waiting retriving data.

I using ASIHTTPRequest for get data from the server. There is how I check my request

- (void)testSignIn {

    self.request = [[Requests alloc] init];
    [self.request signInWithEmail:@"some.email@gmail.com" andPassword:@"123456"];

}

Here I have a problem. If in this method I will insert STFail befaore I get response it will complete with error in each time (because retrive data will take it some time and this is not a synchronize reuest)

How to resolve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:28:37+00:00Added an answer on June 8, 2026 at 5:28 pm

    If you really want to test network code in a unit test:
    Switch to using GHUnit, which actually contains support for waiting for asynchronous events.

    GHUnit Examples

    But really, you shouldn’t be doing this. In the above test, what are you testing? Your backend service or your Requests class?

    Strictly speaking, Unit Tests should test a unit of code not being going off to the network to retrieve data.

    If possible, restructure your tests to provide static test data that will test your functions. You want your tests to be as reliable and consistent as possible. By introducing the network, you are setting yourself up for inconsistent tests (when the network is down, or slow), which may lead to your tests being disabled (assuming you’re working in a team)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I use FlexUnit to unit test a File Upload and delete? Are those
For a unit test I want to use the Range attribute from NUnit to
use Service layer to persist data into database. But the Unit Test does not
I use Microsoft Visual Studio test Tools assembly for unit testing. And from one
Question : Can anyone tell me why my unit test is failing with this
I want to Unit Test my application which use MSMQ but i found no
I want to unit test a RESTful interface written with Apache CXF. I use
I am new to use moq. I am into creating some unit test case
Sometime, when the Unit Test of a class has been done and method use
I'm writing unit tests using Test::More and Test::Output. I use Test::More to validate the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.