Swift Unit and AVFoundation testing: how to check for the presence / absence of a valid capture device?
I am coding an application that uses the camera (s) of the device and this is my first time trying to use TDD seriously.
I am trying to test this feature, specifically:
func startRunning(cameraPosition: CameraPosition) -> CaptureSessionPreview?
where CameraPosition
is the enum (front and back) and CaptureSessionPreview
is the protocol that defines the object / structure on which the video slot is displayed (for example AVCaptureVideoPreviewLayer
).
I would like to write tests to determine what happens when there is or is not a specific camera (front or back).
I am using a mock AVCaptureDevice
that I can initialize with a position and inject to check for the presence or absence of a device, but I also want to check that I can actually start AVCaptureSession
with (otherwise I should still get an error).
I'm trying to start init AVCaptureDeviceInput
with a valid layout (it always returns nil for me). Is this even the best way to test it? Help?
source to share
No one has answered this question yet
Check out similar questions: