Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WatchOS Unit Testing

I am building an app for Apple Watch and want to write a simple unit test. I looked around and didn't find a single way to add a unit testing bundle for watchOS code. Xcode supports unit tests for iOS, macOS and even tvOS but not for watchOS. Has anyone ever done it and if yes what is the trick?

like image 861
sam Avatar asked Nov 17 '15 11:11

sam


People also ask

What is unit testing in iOS?

A unit test is a function you write that tests something about your app. A good unit test is small. It tests just one thing in isolation. For example, if your app adds up the total amount of time your user spent doing something, you might write a test to check if this total is correct.

How do I test my watch OS app?

Running tests from the watchOS apps schemeAt the top of Xcode, select the watchOS app scheme then select Edit Scheme…. Click on Test from the left options.

Is Unit Testing worth the time?

Unit testing ensures that all code meets quality standards before it's deployed. This ensures a reliable engineering environment where quality is paramount. Over the course of the product development life cycle, unit testing saves time and money, and helps developers write better code, more efficiently.

What is difference between unit tests and UI test in Xcode?

The really short version is that unit tests have access to the code in your app (or whatever kind of module you are building) and UI tests do not have access to the code. A unit test only tests one single class per test.


2 Answers

No, watchOS does not currently (as of watchOS 3) support unit or UI testing. What you can do is cross-compile non-watchOS-specific code to a shared library, then unit test that on another platform.

like image 119
Jeff Kelley Avatar answered Sep 30 '22 10:09

Jeff Kelley


This has been added to Xcode 12.5

like image 39
leogdion Avatar answered Sep 30 '22 10:09

leogdion