-
Notifications
You must be signed in to change notification settings - Fork 3
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
Android Native Reporter #8
Conversation
README.md
Outdated
@Test | ||
public void testBridge() throws Exception { | ||
// Wait 5 seconds to receive a test report from Cavy. | ||
RNCavyNativeReporterModule.waitForReport(5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's way too low for a default, given that for a sizable app, first 10-30 seconds might be spent by bundler just bundling the app… And CIs are slow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
[expectation fulfill]; | ||
}]; | ||
|
||
|
||
// Wait for expectation to fulfill. | ||
[self waitForExpectations:@[expectation] timeout:100]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion, to make this simpler for non-platform experts is to also supply this code from the Cavy bundle. Then we could simplify it to:
- (void)testBridge {
[CavyXCTest testBridgeWithTimeout: 100];
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this would look really neat 👌 I'm conscious that this would couple the native reporter to XCTest only..
I agree that the API could be improved though. I had a think about implementing this in a non XCTest specific way using DispatchGroups, so you could have something like:
- (void)testBridge {
[CavyNativeReporter waitForReport:5];
NSDictionary *report = CavyNativeReporter.cavyReport;
long errorCount = [report[@"errorCount"] integerValue];
XCTAssertEqual(errorCount, 0);
}
but it's a definite work in progress!
I'm going to track the idea as an issue and continue to work on it :)
One more general suggestion (sorry to barge in on an unrelated PR) is that it would be amazing if Cavy / CavyNativeReported had a mechanism to detect a bundling failure. What I mean is that we saw many times test fail with the assertion that it timed out (after 10 minuets in our case)… but in reality it didn't time out but tests never began to run, because there was a bundling failure and the JS code never launched. Perhaps it would be possible to observe in AppDelegate/MainActivity whether or not loading JS into RCTRootView was successful or not and then send that message to the test part? Or if not successful throw a native error so that it's immediately obvious in logs that it's bundling that failed, and so that we don't have to wait for the timeout (for large app/library with a lot of tests, a large timeout like 10 minutes might be necessary - and then a failure makes you wait a loooong time for CI). At the very least, I would suggest adding a message to the timeout to let the user know that the timeout might mean that A) Your tests are running for a very long time and you might need to increase the time out, or B) Most likely you had a bundler failure or an early-stage app failure and Cavy never set up successfully |
I got this up and running pretty quickly!
I'm getting a warning from Android Studio, which we might want to ignore, not sure?
|
@jalada - updated for all of the above. I also fixed both the deprecation warnings and added a 'useful links' section for both Android and iOS. |
Includes:
To do: