John Twigg
John Twigg

Reputation: 7571

iOS XCTest take Screenshot

I'm aware of useful tools like facebook/ios-snapshot-test-case but what I'm after is the ability to store a png of the output of a unit test that interacts with a view.

Ideally, I'd like to get it off the simulator and onto the environment running XCode, so that after I run my batch of tests, I have a folder of screenshots of what was rendered.

Does anyone know of a framework or workflow that is good for taking screenshots off the simulator?

Upvotes: 1

Views: 1515

Answers (3)

Tomas Cejka
Tomas Cejka

Reputation: 96

There are more third party libraries to make screen shots in app, you don't need to program it yourself. I needed it just once and I tried KSScreenShot. It wasn't perfect but for my purpose it was enought.

Upvotes: 0

dasdom
dasdom

Reputation: 14073

The awesome snapshot can do this. I use it to generate the App Store screenshots.

Upvotes: 0

bbarnhart
bbarnhart

Reputation: 6710

You can create a function that programmatically captures the UIWindow to a jpg or png. The image can be persisted to disk.

When your test case completes it can call this function.

Upvotes: 0

Related Questions