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

Simplify iOS reporter API #9

Open
AbigailMcP opened this issue May 30, 2019 · 0 comments
Open

Simplify iOS reporter API #9

AbigailMcP opened this issue May 30, 2019 · 0 comments

Comments

@AbigailMcP
Copy link
Contributor

At the moment, to use the report with XCTest you have to have a setup similar to this:

- (void)testBridge {
  // Make a new expectation
  XCTestExpectation *expectation = [[XCTestExpectation alloc] initWithDescription: @"Cavy tests passed"];
  
  [CavyNativeReporter onFinishWithBlock: ^void(NSDictionary* report) {
    long errorCount = [report[@"errorCount"] integerValue];
    if (errorCount > 0) {
      XCTFail(@"Cavy tests had one or more errors");
    }
    [expectation fulfill];
  }];
  
  [self waitForExpectations:@[expectation] timeout:60];
}

Fulfilling the expectation within the block passed to Cavy and waiting on those expectations with [self waitForExpectations:@[expectation] timeout:60];

It would be better to be able to do something like this:

- (void)testBridge {
  [CavyNativeReporter waitForReport:5];
  
  // Pull the error count from the report object.
  NSDictionary *report = CavyNativeReporter.cavyReport;
  long errorCount = [report[@"errorCount"] integerValue];
  
  XCTAssertEqual(errorCount, 0);
}

This might be achievable by adopting a similar technique to the Android module, making the report a public property on the class, and waiting on a Dispatch Group.

Would be great to achieve this without coupling the reporter to XCTest, but that might be tricky.

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

1 participant