IPhone SenTestingKit does not find AppDelegate in target node UnitTestBundle

I am trying to set up unit testing of an iPhone application using Xcode 3.2.3.

I followed the steps at http://developer.apple.com/iphone/library/documentation/xcode/conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html

As far as I could, but I get this error message when I try to create: "((yourApplicationDelegate)! = Nil)" should be true. UIApplication could not find AppDelegate

(This is the default trivial test for the USE APPLICATION UNIT TEST).

I create the target test program for the application, as described in the documentation, and get this error.

Do I need to ensure that all of my non-testing source data is in my test suite?

confuse

-

I have included the source files in my project and it compiles fine, but it still experiences the same UNIT TEST error:

"((yourApplicationDelegate)! = nil)" should be true. UIApplication could not find AppDelegate

The source code matches the template code:

-(void) testAppDelegate {

    id yourApplicationDelegate = [[UIApplication sharedApplication] delegate];
    STAssertNotNil(yourApplicationDelegate, @"UIApplication failed to find the AppDelegate");
}
+3
source share
5 answers

Ensure that the assembly parameters BUNDLE_LOADER and TEST_HOST are specified for the unit test package.

BUNDLE_LOADER = $(BUILT_PRODUCTS_DIR)/YourApp.app/YourApp
TEST_HOST = $(BUNDLE_LOADER)

In addition, in Xcode4, many of the steps described in the Apple manual are not needed (for example, duplicating the purpose of an application). I recommend creating a new project, including unit test, and look around.

+10
source

This is for the OP, if the problem persists and is still relevant, and for forum browsers:

gudielines iOS Development . , , :

Test Suite 'FirstSuite' started at 2010-12-08 21:30:33 GMT 0000
Test Case '-[FirstSuite testAppDelegate]' started.
/Users/TomCruise/Documents/iPhoneDevelopment/PickerLeak/FirstSuite.m:22: error:-[FirstSuite testAppDelegate] : "((app_delegate) != nil)" should be true. Cannot find the application delegate.
Test Case '-[FirstSuite testAppDelegate]' failed (0.000 seconds).

I.e., , .

, , , , . -, . Simulator Device ( AppTesting), iPhone, Build + Run (cmd + return/enter). , 1 (, , ).

, , + cmd + R, (uparrow + cmd + R), , :

2010-12-08 22:59:59.163 PickerLeak[5356:307] -[UIPickerView setFrame:]: invalid height value 200.0 pinned to 180.0 
Test Suite 'All tests' started at 2010-12-08 22:00:00 GMT 0000
Test Suite '/var/mobile/Applications/{number}/PickerLeak.app/PickerLeakTests.octest(Tests)' started at 2010-12-08 22:00:00 GMT 0000
Test Suite 'FirstSuite' started at 2010-12-08 22:00:00 GMT 0000
**Test Case '-[FirstSuite testAppDelegate]' started.
Test Case '-[FirstSuite testAppDelegate]' passed (0.001 seconds).**
Test Case '-[FirstSuite testFail]' started.
/Users/TomCruise/Documents/iPhoneDevelopment/PickerLeak/FirstSuite.m:17: error: -[FirstSuite testFail] : Must... fail.
Test Case '-[FirstSuite testFail]' failed (0.003 seconds).
Test Suite 'FirstSuite' finished at 2010-12-08 22:00:00 GMT 0000.
Executed 2 tests, with 1 failure (0 unexpected) in 0.004 (0.008) seconds

... !:)

Godspeed, .

+1

. BUNDLE_LOADER TEST_HOST, . , Bundle Loader Test Host. , xcode4?, .

+1

, OCUnit. , Google Toolbox Mac GHUnit, .

Blazing Cloud, OCUnit ( GTM/GHUnit) JUnit-, Rspec. Pivotal Rspec , - Objective C. , Cedar, UIKit, iOS .. ; - , : cedar-discuss@googlegroups.com.

0

Source: https://habr.com/ru/post/1753417/


All Articles