Skip to content

Instantly share code, notes, and snippets.

@ob
Created November 8, 2019 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ob/6ec69f569bb7396a06343e56de782aab to your computer and use it in GitHub Desktop.
Save ob/6ec69f569bb7396a06343e56de782aab to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>
@interface TestDumper : NSObject
@end
@implementation TestDumper
+ (void)load {
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *pluginsPath = [mainBundle builtInPlugInsPath];
NSArray* xcTests = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pluginsPath error:Nil];
for (NSString *xcTestBundlePath in xcTests) {
NSString *ext = [xcTestBundlePath pathExtension];
if (![ext isEqual:@"xctest"]) {
NSLog(@"Skipping %@ - %@", xcTestBundlePath, ext);
continue;
}
NSString *path = [pluginsPath stringByAppendingPathComponent:xcTestBundlePath];
NSLog(@"Loading %@", path);
NSBundle *bundle = [NSBundle bundleWithPath:path];
if (!bundle) {
printf("bundle failed to load!\n");
perror("bundle");
exit(1);
}
NSError *err;
if (![bundle loadAndReturnError:&err]) {
NSLog(@"Failed to load bundle: %@: %@", path, err);
}
}
XCTestSuite *dtest = [XCTestSuite defaultTestSuite];
if (!dtest) {
printf("failed in XCTestSuite\n");
exit(1);
}
for (XCTestSuite *testSuite in [dtest tests]) {
NSLog(@"Loaded %@", [testSuite name]);
for (XCTestSuite *ts in [testSuite tests]) {
NSLog(@"Loaded %@", [ts name]);
for (XCTest *t in [ts tests]) {
NSLog(@"Test: %@", [t name]);
}
}
}
// don't actually run the app
exit(0);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment