Running Xcode unit tests during release build

user7195659

I have a number of logic unit-tests (where my project files have a target membership of the App and AppTests). I want to add a call to xcodebuild test-without-building to my build system so that my unit-tests run for each build.

However, the tests cannot run on the release build (because release doesn't build for testing).

Is my only choice to build both the release version and the debug version during my build, so that I can use the debug version only to perform the tests? That's very different and very much worse to the other test frameworks I've used (GTest, Catch). Why can't the tests stand on their own?

mokagio

The test-without-building command is not actually meant to "run the tests without rebuilding the app", but rather it's supposed to be used in tandem with the build-for-testing command.

Please refer to the "Advanced Testing and Continuous Integration" WWDC 2016 session for more info.

The gist is: use build-for-testing to build an .xctestrun file, which is then used by test-without-building to run the tests. This is particularly useful to run big suites across different machines, although I have never done it myself.

Now that we have established that you can't use test-without-building on its own, the only option to run the test from the command line and if they pass build a Release version is to use xcodebuild test, which is going to build the app.

As for the why does it need to be in Debug, I don't have a precise answer. In iOS land, at least in the teams I worked with, the difference between Debug and Release builds is always only on things like the options passed to the compiler in terms of optimization, the architectures to build on, and the type of code signing.

This means that the code that runs in Debug vs Release is exactly the same, and since we already established that you'll need to build the app twice, one to run the tests, one to generate the releasable version, running the tests in Debug seems acceptable.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Xcode 5: Unit Tests not running

From Dev

Error when running unit tests in Xcode 5.0

From Dev

Exception running unit tests with Fakes on build server

From Dev

Running unit tests before each build in Gradle

From Dev

TFS 2013 Build: Running Unit Tests in Parallel on multiple build agents

From Dev

Generating .gcda files after running unit tests on Xcode bot

From Dev

Error running Xcode Unit Tests from Command Line

From Dev

Running unit tests on git submodules (which are also CocoaPods) in Xcode 6.2

From Dev

Error running Xcode Unit Tests from Command Line

From Dev

Running unit tests on git submodules (which are also CocoaPods) in Xcode 6.2

From Dev

Running Unit Tests Fakes Framework on TFS build server | Error

From Dev

Running Unit Tests Fakes Framework on TFS build server | Error

From Dev

xcode 5 - app crashes when running in release build configuration

From Dev

Running QtQuickTest unit tests

From Dev

Resharper Unit Tests not running

From Dev

Utilizing Resources during unit tests

From Dev

How to prevent Android gradle build from running device tests as unit-tests

From Dev

Xcode 5 Tests Not Running

From Dev

TFS merge during build and release

From Dev

OpenCover without running unit tests

From Dev

Running spock unit tests with Maven

From Dev

Running Unit and Integration Tests in IntelliJ

From Dev

Running Spark Unit Tests in IntelliJ

From Dev

Unit tests crashing in Xcode 7

From Dev

Detect whether iOS app is running Debug or Release build without preprocessor macros, for unit testing purposes?

From Dev

Unit tests not run by a "gradle build"

From Dev

Unit Tests, Build Configuration and Internals

From Dev

Running unit tests from the command line fail after upgrading to Xcode 5.1

From Dev

Running unit tests from the command line fail after upgrading to Xcode 5.1

Related Related

  1. 1

    Xcode 5: Unit Tests not running

  2. 2

    Error when running unit tests in Xcode 5.0

  3. 3

    Exception running unit tests with Fakes on build server

  4. 4

    Running unit tests before each build in Gradle

  5. 5

    TFS 2013 Build: Running Unit Tests in Parallel on multiple build agents

  6. 6

    Generating .gcda files after running unit tests on Xcode bot

  7. 7

    Error running Xcode Unit Tests from Command Line

  8. 8

    Running unit tests on git submodules (which are also CocoaPods) in Xcode 6.2

  9. 9

    Error running Xcode Unit Tests from Command Line

  10. 10

    Running unit tests on git submodules (which are also CocoaPods) in Xcode 6.2

  11. 11

    Running Unit Tests Fakes Framework on TFS build server | Error

  12. 12

    Running Unit Tests Fakes Framework on TFS build server | Error

  13. 13

    xcode 5 - app crashes when running in release build configuration

  14. 14

    Running QtQuickTest unit tests

  15. 15

    Resharper Unit Tests not running

  16. 16

    Utilizing Resources during unit tests

  17. 17

    How to prevent Android gradle build from running device tests as unit-tests

  18. 18

    Xcode 5 Tests Not Running

  19. 19

    TFS merge during build and release

  20. 20

    OpenCover without running unit tests

  21. 21

    Running spock unit tests with Maven

  22. 22

    Running Unit and Integration Tests in IntelliJ

  23. 23

    Running Spark Unit Tests in IntelliJ

  24. 24

    Unit tests crashing in Xcode 7

  25. 25

    Detect whether iOS app is running Debug or Release build without preprocessor macros, for unit testing purposes?

  26. 26

    Unit tests not run by a "gradle build"

  27. 27

    Unit Tests, Build Configuration and Internals

  28. 28

    Running unit tests from the command line fail after upgrading to Xcode 5.1

  29. 29

    Running unit tests from the command line fail after upgrading to Xcode 5.1

HotTag

Archive