Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it work for mac apps? #10

Open
serejahh opened this issue Mar 4, 2018 · 8 comments
Open

Does it work for mac apps? #10

serejahh opened this issue Mar 4, 2018 · 8 comments

Comments

@serejahh
Copy link

serejahh commented Mar 4, 2018

It'd be nice to run live tests for mac apps. Are there any restrictions\limitaions?

@polac24
Copy link
Owner

polac24 commented Mar 4, 2018

Hi @serejahh.
Since InjectionTDD requires InjectionForXcode, do you know if it still supports macOS apps?
I tried once to setup sample macOS app with injection but had no luck. Do you have any experience with macOS+InjectionForXcode?

@serejahh
Copy link
Author

serejahh commented Mar 5, 2018

No, but i'd like to try. I'll write here if try.
What was the problem?

@polac24
Copy link
Owner

polac24 commented Mar 5, 2018 via email

@serejahh
Copy link
Author

serejahh commented Mar 5, 2018

Works for me for just created objective-c project. Did you switch off sandbox? I guess that was the problem

@serejahh
Copy link
Author

serejahh commented Mar 5, 2018

Is it ok if I add just sources, not framework?

@serejahh
Copy link
Author

serejahh commented Mar 5, 2018

For TDD I got:

Error loading /Applications/Injection.app/Contents/Resources/InjectionLoader.bundle/InjectionLoader:  dlopen(/Applications/Injection.app/Contents/Resources/InjectionLoader.bundle/InjectionLoader, 265): no suitable image found.  Did find:
	/Applications/Injection.app/Contents/Resources/InjectionLoader.bundle/InjectionLoader: mach-o, but built for simulator (not macOS)
	/Applications/Injection.app/Contents/Resources/InjectionLoader.bundle/InjectionLoader: mach-o, but built for simulator (not macOS)
2018-03-05 20:31:53.851662+0200 xctest[52899:1656849] Warning: Injection for Xcode not found. Please open Injection For Xcode.

But the app is open

@polac24
Copy link
Owner

polac24 commented Mar 5, 2018

Hi! Thanks for a comment. You were right - as iOS developer I was not aware that such capability as sandbox exists at all.
After your suggestion I quickly tried to make it runnning and here are some steps that lead to a working (somehow) POC:

  • create main.m in a test target
  • patch from Injection app test's main.m
  • manually (I know, hacky way) modify "/tmp/injectionforxcode/BundleInjection.h" to change
@interface NSObject(XCTestSuite)
+ testSuiteForTestCaseClass:(Class)testCaseClass;
- initWithName:(NSString *)name;
- addTest:test;
- performTest:tr;
@end

to (note void return types):

@interface NSObject(XCTestSuite)
+ testSuiteForTestCaseClass:(Class)testCaseClass;
- initWithName:(NSString *)name;
- (void) addTest:test;
- (void) performTest:tr;
@end
  • To a test target add only a single file main.m with a given content:

#import <XCTest/XCTest.h>

@interface TDDTestKeeper : XCTestCase

@end


@implementation TDDTestKeeper

+ (BOOL) skipInjection{
    NSDictionary *environment = [[NSProcessInfo processInfo] environment];
    NSString *skipValue = [[environment objectForKey:@"INJECTION_TDD_SKIP"] uppercaseString];
    return [@[@"TRUE", @"YES"] containsObject:skipValue];
}
+(void)initialize{
    if ([self skipInjection]){
        return;
    }

    [NSRunLoop.currentRunLoop run];    
}
@end

@polac24
Copy link
Owner

polac24 commented Mar 5, 2018

As macOS developer, can you please verify it these steps are acceptable and InjectionTDD works OK for your already existing mac project?
If so, I will try to integrate them within a tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants