In ViewControllerTestCase is not possible to wait after configure(vc:testCase:)method
danieleformichelli opened this issue · comments
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
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:
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.
Fixed in TempuraTesting 5.0.0