idb/FBSimulatorControl/Interactions/FBSimulatorInteraction+XCTe...

62 строки
2.5 KiB
Objective-C

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "FBSimulatorInteraction+XCTest.h"
#import <CoreSimulator/SimDevice.h>
#import <FBControlCore/FBControlCore.h>
#import <XCTestBootstrap/XCTestBootstrap.h>
#import "FBProcessLaunchConfiguration.h"
#import "FBSimulator+Private.h"
#import "FBSimulatorApplication.h"
#import "FBSimulatorControlOperator.h"
#import "FBSimulatorError.h"
#import "FBSimulatorInteraction+Private.h"
@implementation FBSimulatorInteraction (XCTest)
- (instancetype)startTestRunnerLaunchConfiguration:(FBApplicationLaunchConfiguration *)configuration testBundlePath:(NSString *)testBundlePath
{
return [self startTestRunnerLaunchConfiguration:configuration testBundlePath:testBundlePath workingDirectory:self.simulator.auxillaryDirectory];
}
- (instancetype)startTestRunnerLaunchConfiguration:(FBApplicationLaunchConfiguration *)configuration testBundlePath:(NSString *)testBundlePath workingDirectory:(NSString *)workingDirectory
{
NSParameterAssert(configuration);
NSParameterAssert(testBundlePath);
NSParameterAssert(workingDirectory);
[FBFoundationInitializer initializeTestingEnvironment];
return [self interactWithBootedSimulator:^ BOOL (NSError **error, FBSimulator *simulator) {
FBSimulatorTestPreparationStrategy *testPrepareStrategy =
[FBSimulatorTestPreparationStrategy strategyWithTestRunnerBundleID:configuration.bundleID
testBundlePath:testBundlePath
workingDirectory:workingDirectory
];
FBSimulatorControlOperator *operator = [FBSimulatorControlOperator operatorWithSimulator:self.simulator];
FBXCTestRunStrategy *testRunStrategy = [FBXCTestRunStrategy strategyWithDeviceOperator:operator testPrepareStrategy:testPrepareStrategy logger:simulator.logger];
NSError *innerError = nil;
FBTestManager *testManager = [testRunStrategy startTestManagerWithAttributes:configuration.arguments environment:configuration.environment error:&innerError];
if (!testManager) {
return [[[FBSimulatorError
describeFormat:@"Failed start test manager"]
causedBy:innerError]
failBool:error];
return NO;
}
[simulator.eventSink testmanagerDidConnect:testManager];
return YES;
}];
}
@end