Various assembly configurations for test circuits

Is there a way to run unit tests in build tests and debug performance tests in release builds without manually selecting and running individual schemas?

I have a unit test and a performance testing scheme. In the test configuration for the unit test circuit, I chose the debug assembly, and for the performance testing circuit, I chose the release assembly. If I run each circuit individually, I get a debug build and release build respectively.

If I create another circuit that runs both of these circuits, then this new circuit will have its own build configuration. If I configure the debug configuration for this new circuit, I will also get a debug build for my performance tests.

+8
unit-testing xcode xcode8 xctest xcode-scheme
source share
2 answers

You can use different test packages and include / exclude what you want.

I mean creating my own custom test targets (packages) and using the Xcode Test Navigator.

So, for example, creating the target MyUnitBundleTests and MyPerformanceBundleTests . They would be two separate test "packages" where you decide to include / exclude classes, methods, etc.

The Test Navigator displays a hierarchical list of test packages and related classes, methods, etc. included in the project.

You can enable and disable test suites, classes, and methods selectively using Ctrl by clicking on items in the list of test navigation systems and selecting "Enable or Disable" from the context menu, thereby enabling or disabling elements in the circuit.

Testing with Xcode - Quick Start

Testing with Xcode - Performing Tests and Search Results

There are several additional interactive ways to run tests. Xcode runs tests based on which test targets are included and included in the schema. The test navigator allows you to directly control which goals, classes, and test methods are enabled, enabled, or disabled in the circuit without using the circuit editor.

enter image description here

Not sure if this is what you want, but this is the only option I can come up with for testing without going to the Schema Editor.

+1
source share

There may be a way to achieve the desired behavior, but this is more of a hack.

The main problem that I see is the desired assembly configuration for the test circuit action. Since the build configuration applies to all the goals of the circuit, you need to find a way to trick Xcode into creating your goal with Debug and Release settings. That being said, here is the idea:

  • Export the release configuration for your purpose to the xcconfig file ( xcodebuild -scheme "schemeName" -showBuildSettings >> release.xcconfig and make sure that it contains only release parameters)
  • Create another goal for performance tests that build the same source files.
  • Set the debug configuration of this new target to the aforementioned xcconfig file of the release configuration (basically this is the part where we cheat on Xcode)
  • Add the original and newly created target to the assembly action of your circuit and add test packages (provided that they are in a separate test suite)
  • Select the debug build configuration for the test action.

If you test your circuit, it should now create sources in both debug and release, and should run your unit tests in the debug configuration configuration and performance tests in the release configuration.

The setup is a bit fragile as you need to add new source files for both purposes. You should be able to automate the process using ruby ​​script and xcodeproj gem, though.

Hope this helps.

0
source share

All Articles