Asynchronous unit test not being called by SenTestCase

When I am running my unit test, I don't reach my breakpoint, and I think that the test isn't properly running my code.

I am trying to do an asynchronous test, which is part of my difficulty.

How do I set up the test so that testLookupBook will be called, as I hope that that will lead to everything else being called properly.

I am guessing that the function to test should be somewhere in the header file, but I did start my test method with test.

Here is my header file:

@interface jabBookScanTest : SenTestCase { jabBookScan *instance; NSArray *searchResult; } @end

And the implementation for the test is here:

- (void)MethodNameToCallBack:(jabBookScan *)manager resultFromServer:(NSArray *)s { searchResult = s; } - (BOOL)waitForCompletion:(NSTimeInterval)timeoutSecs { NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeoutSecs]; BOOL done = false; do { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeoutDate]; if([timeoutDate timeIntervalSinceNow] < 0.0) break; } while (!done); return done; } - (void)testLookupBook { NSDate *fiveSecondsFromNow = [NSDate dateWithTimeIntervalSinceNow:5.0]; [instance lookupBook:(NSString *)@"9780262140874"]; [[NSRunLoop currentRunLoop] runUntilDate:fiveSecondsFromNow]; STAssertTrue([self waitForCompletion:90.0], @"Failed to get any results in time"); }


I would do like this

- (void)testLookupBook { NSDate *fiveSecondsFromNow = [NSDate dateWithTimeIntervalSinceNow:5.0]; [instance lookupBook:(NSString *)@"9780262140874"]; WAIT_WHILE(searchResult == nil, 1.0); }

The WAIT_WHILE(expressionIsTrue, seconds)-macro will evaluate the input until the expression is not true or the time limit is reached. Underneath it is using the NSRunLoop-pattern. You can find the project here:


I forgot to add the method to my header file.

@interface jabBookScanTest : SenTestCase<jabBookScanDelegate> { jabBookScan *instance; NSArray *searchResult; } - (void) testLookupBook; @end

人吐槽 人点赞


  • OPAL-Regarding implementing construct call graph in OPAL
  • prevent Custom ListView Refreshing on scroll. I want to stop refreshing
  • How to select CollectionView cell in RxSwift
  • If this is the right way to use a customised string property in Objective C, why can’t I extract the
  • Difference between Shift + F6 and right click run?
  • How to use a “long int” in GNU Prolog?
  • Call method on parameter of generic type
  • Cyclic function/type dependency in F#
  • Ambiguous method call intelliJ 15
  • How to obtain amount of transferred data through Wi-Fi from other applications?
  • Can't push view controller after overriding openURL
  • How to get N most often words in given text, sorted from max to min?
  • What should I do to speed up a slow GWT app using MVC
  • Adding a Listener to a Google Map
  • Good and clear understanding of the git branches diverged issue? [duplicate]
  • Should all reference to programmactically created subviews declared as weak?
  • Apache MQ - JMS message selector
  • Handling session data using a static class
  • Confused about STS and WIF
  • Get glyph widths by fontforge script
  • Eclipse not recognizing the android device
  • Spring Data autowire the repository interfaces directly
  • CALayer and CAAnimation's dynamic resolution of unimplemented property accessors
  • Getting IP address, port and connection type from a socket fd
  • Passing object reference using RMI
  • Parsing large XML using iterparse() consumes too much memory. Any alternative?
  • Cant use TabBar delegate methods
  • How to hold data structures in memory G-wan with Java / Scala
  • How to typecast an id to a concrete class dynamically at runtime?
  • ComponentLookupError: (, '') with Dexterity references
  • Using enum as interface key in typescript
  • Adding State in Decorator Pattern
  • ASP MVC5 Identity User Abstraction
  • tcltk in portable R
  • Direction of target annotation when outside of visible area
  • Android Fragments and Activities
  • .Net Dependency injection in unit of work pattern using repositories
  • How to know Typing Status in XMPP openfire using Smack
  • Vertical alignment of icons with various size in JRadioButtonMenuItem
  • Does TWebBrowser updates with IE?
  • Should overloaded methods with value types be consolidated into a generic method?
  • Group by - multiple conditions - MySQL
  • Modal View prevents other views from rotating
  • Why do Rhino Stubs allow me to set expectations on them?
  • Android Inter-app relations
  • Invalid response while accessing the Selenium Server
  • xcode: Using a UIImageView subclass with NSTimers
  • WriteFile returning error code 87
  • JSR 352 :How to collect data from the Writer of each Partition of a Partitioned Step?
  • retrofit 400 Bad Request
  • how to pass an object containing with drawable parameter to another activity through intent using Pa
  • Exposing JAX-WS web service as spring bean
  • Why does VS2005/VB.NET implement the IDisposable interface with a Dispose(disposing as boolean) over
  • typescript history js conflict
  • How do I send an array or collection of complex objects using web services in Java (e.g. Axis2)?
  • UIScrollView not scrolling programmatically in iOS 6 & 7 both
  • Assign states various values in Processing
  • How can I map over a record using interfaces
  • Which to use , abstract class or interface in F#?
  • Number keypad with missing keys in ios9
  • React Bootstrap Checkbox in Nav -> NavItem does not rerender on click
  • Repository method only works returning the whole entity instead of some properties
  • How to write data to a text file on Arduino
  • communication between Android devices from different computer
  • ASP.NET MVC Drop Down List
  • Is it possible to add PHP scripts in a Java server?
  • Dependency Injection for Presenter
  • jax-ws Undefined port type with client and server in separate projects
  • Retrofit 2.0 + GSON Unable to invoke no-args constructor for interface
  • Error installing pHash on Ubuntu
  • How do I use a (generic) vector in go?
  • Getting an arbitrary property from a JavaScript object in Dart
  • Accessing derived class' member functions in base template function
  • java: PropertyChangeSupport for Map or EnumMap?
  • Typescript number of arguments error
  • Where is iOS app customer reviews section in newly revamped (in Sep 2015) iTunes connect UI
  • How to statically link OpenSSL with my app in Xcode?
  • SpringData MongoDB cannot determine IsNewStrategy during Auditing
  • WatchKit app “Unlock to activate”
  • Create WifiConfiguration with Delphi XE5 for Android
  • Accessing static field in annotation
  • The remote server returned an error: NotFound #2
  • WPF event property changed?
  • How to check user group in ClearCase client server
  • How to redraw the console screen so it would appear as screen was cleared?
  • Abstract classes, interfaces and Autowired
  • spring wiring, singleton versus prototype
  • View Pager - slide to next page programmatically with static variable
  • How can I create new auth_user and auth_group on Web2py running on Google App Engine (GAE)?
  • How to set spark.driver.memory for Spark/Zeppelin on EMR
  • Instantiating generic class and implementing generic interface
  • @PostConstruct Interceptor with @Named @ViewScoped not invoked
  • Unusual 'Headers already sent' error. No whitespace nor changing of the header
  • How do I get basic security to apply when programmatically creating WebChannel in WCF?
  • ClearCase checking in and out using c#
  • Extending the User Interface in Outlook 2010 to add to the Right Click menu
  • How do I set the IP Address of a device using Windows Universal App?
  • How can I make an interface property optionally read-only in VB.NET?
  • Calculating Unique events in Google-Bigquery
  • Can my sql server send messages to activemq server without any java app in between
  • Invoking a Javascript from Lotus Notes on click of a button
  • using aspnet identity with custom tables
  • Android: AIDL refusing to generate code from aidl file defining parcelable
  • Spring Data REST Neo4j create a relationship
  • Instantiating an object in a worker thread with Dependency Injection
  • UITableView numberOfRowsInSection Will Not Load More than One Row
  • How can i create a keyboard listener in Android?
  • Case insensitive regex for non-ASCII strings does not work?
  • How to use fmt.Sscan to parse integers into an array?
  • Swift class that inherits an Objective-C Base Class not casting to correct type
  • UITextField — observe changes to selectedTextRange?
  • iWatch: WKInterfaceLabel is it possible to stop text from being cut off with “…” at the end of a lab
  • How to convert IPictureDisp to System.Drawing.Image
  • Camel: Bean Proxy to CXF Endpoint
  • Extending the attributes inspector in interface builder
  • Sticker Pack Interface Builder Storyboard Compiler Error Group
  • Change array dimensions at runtime
  • ClassCastException when using embedded glassfish for unit tests
  • Dynamic search by criteria
  • Get all derived types of a type
  • iterator_range in header file
  • When to use clone() and how actually addAll() and add() works
  • How do I make my Linq to Sql entity implement INotifyPropertyChanged
  • How to declare a typescript property that implements multiple interfaces
  • NSControl isEnabled only available in OS X v10.0 through OS X v10.9
  • Swagger/Swashbuckle list acceptable values?
  • Object Mapping an empty response with RestKit
  • Adding child progress for multiple file download
  • Disable click event listener of square temporally (Color Picker Game)
  • Windows phone 8.1 Flyout hide with behaviour issue
  • Monitoring Servicemix with Hyperic HQ
  • Does passing a struct into an interface field allocate?
  • Can NSRange determine if a snippet of text exists in a larger string?
  • Dangers of @ComponentScan'ing all packages with filters
  • Python: selenium-chromedriver error on new browser object
  • How to create a Must Not Match attribute for email address
  • JUnit testing package private class in Maven formatted project
  • How to modify search result page given by Solr?
  • Apple Watch page based interface overflowing on initial controller
  • How can I figure out what UITableViewCell I'm clicking on during a search?
  • How to run .ear file in JBoss 6?
  • How to map clock gate to tech library cell
  • Is co-variance safe here?
  • Generic collection in generic class
  • Subviews for custom UIView with Nib (.xib) don't load?
  • Why can't I create PHP project using Eclipse Juno?
  • Threads in jMonkey and Nifty?
  • Windows Forms switch between Panels
  • Decoding PubNub messages with golang JSON
  • Objective-C – access extern const with a string containing its name? [duplicate]
  • Streamed transfer restrictions with WCF
  • What's the alternative to IValueFormatter in AutoMapper?
  • Guice, Injecting TypeLiteral when using @AssistedInject
  • How to clear out the contents of a map when clear() method call throws UnsupportedOperationException
  • what is browser's native support according to selenium webdriver
  • send data back from jsp iterator to struts action class
  • JOOQ nested condition
  • Single virtual attribute definition for multiple fields
  • How to set the navigation bar to the top in Table View?
  • How can I create a plugin mechanism that calls functions only when the plugin is available?
  • How to accept a collection of a base type in WCF
  • Does “internal” visibility modifier in Kotlin work yet?
  • How to get Fully qualified domain name in unix
  • How to make stdcall from Go
  • Mercurial: Identify file name after rename
  • Why are “sc.addFile” and “spark-submit --files” not distributing a local file to all workers?
  • Comparing user's facebook/twitter friends to site's users in Python/Django
  • unrecognized selector with category NSMutableData
  • Why can't UI components be accessed from a backgroundworker?
  • C++ pointer value changes with static_cast
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • Firefox Extension - Monitor refresh and change of tab
  • Saving Changes After In-App Purchase Has Been Purchased
  • Row Count Is Returning the incorrect number using RaptureXML
  • C# - Serializing and deserializing static member
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • Comment

    用户名: 密码:
    验证码: 匿名发表


    查看评论:Asynchronous unit test not being called by SenTestCase