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

In ViewControllerTestCase is not possible to wait after configure(vc:testCase:)method #80

Closed
danieleformichelli opened this issue Mar 31, 2020 · 3 comments
Assignees

Comments

@danieleformichelli
Copy link
Contributor

danieleformichelli commented Mar 31, 2020

Current Implementation

In the current implementation of ViewControllerTestCase, the VM of the view must be set in the configure(vc:testCase:) method.
The method is called only after the isViewReady(view:identifier:) returns true, and after that the snapshot is immediately taken.

Problem

In case a UITest needs it, there is no way for the test to wait for some condition after that the configure method is called.

Possible Solution

Call the configure(vc:testCase:) method at the beginning of the test case, and then wait for isViewReady(view:identifier:) to return true to actually take the snapshot.

This requires some refactoring of the ViewControllerTestCase:

  • at the moment all the test cases are run together as asynchronous tasks on the main thread
  • each task checks if the view is ready:
    • if it is ready, it invokes the configure method and takes the screenshot in stack
    • if not, it reschedules itself on the main thread

In case we want to configure the test case and then wait for it, we cannot schedule all the test cases together, otherwise they will conflict with each other trying to configure the view.
Instead we should execute the test case sequentially so that only one test case is in progress at any single moment and it can leave the main thread and wait until the view is ready to take the snapshot

@smaramba
Copy link
Contributor

hey! it would really help me if you can describe an example of which kind of condition you want to test or in general the use case you want to unlock with this. thanks! :raisedhands:

@smaramba
Copy link
Contributor

As discussed offline with AR a possible use case is when you want to snapshot a view with a AVPlayer that needs to render the frame of an AVAsset.

@smaramba
Copy link
Contributor

Fixed in TempuraTesting 5.0.0

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

3 participants