Can you run unit tests as part of building your app in Xcode 5? - xcode

In Xcode 4.x any unit tests (logic tests) could run as part of building your main target.
Is a similar setup possible for Xcode 5?
Update
The issue boils down to Xcode launching the simulator as part of running logic tests. That wasn't the case with Xcode 4.x
Have created a radar to track this http://openradar.appspot.com/15859153

To build and run unit tests after building the other targets in the active scheme, use command-U.

Related

Appium Tests in Actual Mobile App Dev Project

I have been doing some hands on labs in Appium for a couple of weeks now, using tutorials on YouTube, Udemy and other sources. I am pretty much comfortable in running those tests using sample APKs in these tutorials.
Now, I would like to also understand details on how Appium tests would be run on an actual Mobile App Dev project using JUnit or TestNG where we do not work on the APK, but rather that the automated tests be triggered during build using IntelliJ and Gradle. Running the automated tests manually does not make sense, because these tutorials do that only rather than the tests being kicked off during build. Any of you'll with live experience with Bitrise - if you can also give your inputs, it would really help since in my project Bitrise would be used as well.
Any inputs on this would be greatly appreciated!
Thanks in advance.
PS - I am newbie tester :)
i use Bitrise, but only use them as a continuous integration (CI), I don't use mobile devices there. I use aws device farm to run automated tests.
When you said
Running the automated tests manually does not make sense
it depends: project size, test suite size, how many new features are released on each new pull request (PR), how many new features are released in each new version, execution time of everything, Costs
The value of having automated tests that fire on every push/commit , PR or Release should be evaluated.
For example, if you use the testing pyramid concept:
Unit Tests (owner is same developer), check each build
Service Tests (owner: backend and automatic QA) check each build
User Interface Tests (QC and automatic QA) verify each new version or Release

Code Signing macOS App for Testing on Travis CI

I'm trying to add automated tests to my macOS app on Travis CI, but can't quite figure out code signing.
My (private) GitHub repository is set up to trigger Travis build jobs when I push to master.
For iOS projects, Xcode builds/runs/tests the project for the Simulator platform, so no code signing is required for testing (signing with a distribution identity is necessary to deploy a build, of course. But I just want to run unit tests).
But for macOS apps there is no "Simulator": the code is built and run on the development machine itself.
This article explains how to add distribution code signing artifacts to Travis' machine, so it can build/sign a distribution binary for iOS.
I have modified the steps explained there to use macOS development artifacts instead of iOS Distribution ones. The scripts that decrypt my artifacts and install them on the Travis machine seem to work with no problem.
The Problem
However, unlike for distribution, development provisioning profiles contain a specific list of devices on which builds are allowed to run; in my case, my profile obviously only contains de device ID of my local machine. Obviously there is no way I can get the device ID of the mac that Travis uses, and even if I could, the build obviously runs on a different machine each time.
How Can I Build and Unit-Test macOS Apps on Travis CI?
TL; DR:
I solved the code-signing problem by disabling code-signing altogether (it isn't needed for running unit tests), as explained in this brilliant answer by #robmayoff.
The Details
I still need code-signing for testing my app locally (it uses entitlements to read from/write to user-selected files and folders). So I created a new configuration in Xcode by cloning Debug, named UnitTest.
I disabled code-signing and set Development Team to "none" for this configuration.
Next, I created a dedicated scheme (shared, of course) that uses the UnitTest configuration for build and test. I had to do this in both the App target and the Tests target (I gave up on the UI tests because they require Accessibility enabled to run, and the remote machine does not have those permissions). I had to do this because I couldn't get the xcbuild tool to use the UnitTests configuration.
I haven't quite got my Travis build to successfully complete yet, but I've overcome most obstacles (code-signing included).
Hope this helps someone!
Update
I finally got Travis CI to successfully build and test my app. Off-topic, but my code had the following issues:
Deployment target of macOS 10.15 (latest available image on Travis is 10.14)
The project was linking against CryptoKit.framework (available only since 10.15!); had to replace it with similar functionality in CommonCrypto.
Somehow the issues above didn't prevent building the app, only running the tests. I was getting an 'image not found' error for CryptoKit.framework.

Having separate schemes for test targets in Xcode?

We have the following project structure:
Workspace:
- app project
- cocoapods project
App scheme:
- app target (run)
- ui test target (test)
- unit test target (test)
After upgrading to Xcode 10, Xcode insists on building the entire project, including pods and ui tests, every time I run a single unit test, which is a quite heavy and slow process.
If i create a seperate scheme which only include the unit and/or ui tests, it only rebuilds the tests when I run them. Just as I want.
However, as they are no longer member of the main app scheme, I can no longer press Test on the main scheme, as it no longer contains test targets.
My question is then: Is it normal or recommended to have seperate schemes for tests, or can I prevent the entire project from being rebuild in another way, when running a single unit test?
(note: I have set the Host Application setting to None on the unit tests, so I don't get why it always builds the entire project anyway?)
Why not both? In your "Test All the Things" scheme, add each test target. This scheme should be shared.
But when I'm working in one target, I make a scheme for it alone. (More accurately, AppCode creates one for me.) Such schemes are not shared.

XCUITest pointing to Unit Test target

I'm working on adding UITest to my iOS app. I've gone through the steps to create the new UI Test Target, but when I try to even run the sample test, it seems to be pointing to the same target as my Unit Test (which inevitably fails)
Where do I go in Xcode to configure the target for UI tests?
Thanks!

How to run a subset of the unit tests with Xcode 4

Xcode 4 introduces the scheme feature. With which you can create different schemes for your project. Under the test item in a scheme you can select which tests to run. However, I'm finding that all the tests are run, not just the ones I'm selecting. How can I just run a subset of my unit tests?
I suspect my problem is related to the fact that my project and unit tests were originally created with Xcode 3 and imported into Xcode 4.
There was an earlier question about this sort of problem, but my question is specifically about Xcode 4.0.2.
This was fixed in a post 4.0 release of Xcode. I'm using 4.5 and it is fixed this release, but I don't know the exact release it was fixed in.

Resources