I had a project with 3 targets:
The app target
Unit tests target (host app >> 1.)
UI tests target (target app >> 1.)
Now, after I added a new app target for a different branding (with slight changes):
The app target
The new app (new branding)
Unit tests target (host app >> 1.)
UI tests target (target app >> 1.)
I realised that the unit and UI tests have specific target applications. For the new app, 90% of the tests will be the same. Is there a way to setup the test targets to run twice, once for each of my apps/brandings? (maybe with extern tools?)
After some time I found out that what I needed was different targets.
These are my targets now:
The app target
The new app (new branding)
Unit tests target (host app >> 1.)
UI tests target (target app >> 1.)
Unit tests target (host app >> 2.)
UI tests target (target app >> 2.)
To run the tests (or any subset of tests) twice against different apps, you will need two schemes, and you will need to invoke them separately.
If you want this to be a single-action process, create one scheme for each target app with the correct tests selected to run, then create a shell script that runs tests for those two schemes, one after the other. Then you can just run the script to have tests run against both apps.
To simplify the xcodebuild command, you can use Scan, and to automate the process, you can use Jenkins to run your script on a regular basis, or on triggers like a new commit being pushed to your repository.
Scan works nicely with multiple schemes - add them both to the Scanfile and then have your shell script run them sequentially. In Ruby:
`scan --scheme "SchemeOne"`
`scan --scheme "SchemeTwo"`
As Daniel stated you can use the same files in 2 different test targets. I am attempting this now, I will let you know how it goes. I found the info at the tutorial below:
Tutorial on using same files from 2 test targets
Related
I create an application with multiple build config, bundle id, and product name. I can run the unit test but in the unit test code, there is an error shows No such module 'ProjectName' like in the picture below. Still, it can run the unit test and the test is passed as well. It can't use the auto complete, though.
I have cleaned the build folder and restart the Xcode but it's not work.
I don't know what's going on. Could someone give me some workaround?
Update
I found the solution. Just change the build scheme in Use [build scheme] for command-line builds to your unit test build scheme test target at the project level on info tab. Then everything works fine.
just try to clean and restart Xcode it will work properly
Delete derived data https://programmingwithswift.com/delete-derived-data-xcode/
Clean the project with cmd + k
Build and re-run the unit tests with cmd + u
I found the solution. Just change the build scheme in Use [build scheme] for command-line builds to your unit test build scheme test target at the project level on info tab. Then everything works fine.
I’m new to the Calabash iOS automated testing. I have installed “Xcode 4.2”, “Ruby version 2.0.0p643” and “calabash-cucumber gem” on Snow Leopard (version 10.6.8)
I ran the command “calabash-ios setup” and created a target (test-cal target) for my test iOS project. With this command, CFNetwork.framework and calabash.framework are added to the test-cal target.
After that, I ran “calabash-ios gen” in terminal and created a subdirectory called features and manually added features subdirectory to test-cal target.
I wrote a test script in “sample.feature” file under the features folder and then executed the cucumber command in terminal to test the script.
After running the command it is giving me following error:
Scenario: Sample test # features/sample.feature:3
Unable to auto detect APP_BUNDLE_PATH.
Have you built your app for simulator?
Searched dir: /Users/octaneconference/Library/Developer/Xcode/DerivedData/Test-frkimcejhwemmaaapwknwfwvhnmb
Please build your app from Xcode
You should build the -cal target.
Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb
This should point to the location of your built app linked with calabash.
(RuntimeError)
./features/support/01_launch.rb:29:in `Before'
Given the app has launched # features/steps/sample_steps.rb:1
And then the Sound Enable screen will appear # features/sample.feature:5
When click on "NO" button # features/sample.feature:6
Then Menu screen will appear in the screen # features/sample.feature:7
Then take a picture # features/sample.feature:8
Failing Scenarios:
cucumber features/sample.feature:3 # Scenario: Sample test
1 scenario (1 failed)
5 steps (1 skipped, 4 undefined)
0m0.965s
You can implement step definitions for undefined steps with these snippets:
Given(/^then the Sound Enable screen will appear$/)
do
pending # Write code here that turns the phrase above into concrete actions
end
When(/^click on "([^"]*)" button$/) do |arg1|
pending # Write code here that turns the phrase above into concrete actions
end
Then(/^Menu screen will appear in the screen$/)
do
pending # Write code here that turns the phrase above into concrete actions
end
Then(/^take a picture$/) do
pending # Write code here that turns the phrase above into concrete actions
end
I’d appreciate any suggestions/thoughts regarding fixing this issue.
For starters, please ensure that you are using at least OSX Yosemite or later, Xcode 6 or later (preferably >= 7), and please ensure you have the latest calabash-cucumber gem (at the time of writing, 0.17.0). You can verify this by running
calabash-ios version
Secondly, from where are you running the cucumber command? If you are trying to get a test to run on a simulator from an xcode project, you'll need to be in the same directory as <app_name>.xcodeproj . As the error message suggests, you'll also need to make sure you've actually built the project for the simulator prior to running.
If you are trying to run the test on a simulator app bundle (a folder with a .app extension), then you can instead run:
APP_BUNDLE_PATH=/path/to/appname.app DEVICE_TARGET="<UUID>" cucumber
(you can find the uuids of your simulators by running instruments -w devices )
For what it's worth, I'd also recommend checking out the calabash-sandbox for a simplified ruby setup.
When clicking "Build and Run" for an iOS project, Unity generates an Xcode project, fires up Xcode, builds the project, and runs it on the device. I'd like to run a shell script after Xcode finishes building but before it runs. If this were a mere Xcode project, I could simply add a "Run Script" entry to the Build Phases tab, but since this project is auto-generated by Unity I'm not sure how to proceed.
(I'm running OS X Yosemite, if it matters.)
Depends on how much work you want to put into this.
Solution A: Using Unity's PostProcess
You could use Unity's PostProcess, to modify the Xcode project accordingly.
Just mark a static method with the [PostProcessBuild] annotation, and Unity will execute it after the Unity build.
Example:
[PostProcessBuild]
static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
{
// modify the Xcode project here, or run the shell script directly (if it is ok to do this already here)
}
Sources:
Source: http://docs.unity3d.com/412/Documentation/ScriptReference/PostProcessBuildAttribute.html
Python script to modify Xcode project (not sure if it can add a shell script in build phases): https://github.com/kronenthaler/mod-pbxproj
How to start a process in C#: How do I start a process from C#?
Solution B: Append the Xcode Project
You could modify your Xcode Project accordingly, and afterwards just use Append when starting the next build and Unity asks what to do, when detecting that the folder already exists.
Solution C: Do it manually
Use Build instead of Build And Run
Modify the Xcode project after Unity finished it's build
Manually Run on the Device using Xcode
Solution D: Run the build in batchmode / use CI like Jenkins
You can invoke the build from the command line (terminal), and do what ever you want during/between the different build steps. But as this is a lot of work, I'd recommend to take a look at a CI like Jenkins. It comes with an installer for Mac OS X and is not that hard to set up. I guess there is a lot of documentation and Q&As about it.
Jenkins: http://jenkins-ci.org
I hope there's something that fits your needs. Just let me know if you need some more help or information. Cheers.
Each time I build my iOS project, I'd like to it also build a couple OS X projects. These are command line tools. I don't care if they're included in the Archive, I just want to make sure they compile correctly each and every time.
They're little command line tools for specific tasks which access the same libraries. In the past, I've built these far less frequently and as a result they suffer from code rot. I'd like to build them each time I build the iOS project, even when I just Build in Xcode.
To do this, I tried dragging the projects into my iOS project and set them as dependancies.
This works fine in the IDE, but when I try to build via xcodebuild:
xcrun xcodebuild -sdk iphoneos -workspace AppName.xcworkspace \
-scheme AppName archive
I get an error that looks like this:
=== BUILD TARGET dslfi OF PROJECT dslfi WITH CONFIGURATION Release ===
Check dependencies
target specifies product type 'com.apple.product-type.tool', but there's no such
product type for the 'iphoneos' platform
** ARCHIVE FAILED **
The following build commands failed:
Check dependencies
(1 failure)
Is there any way to continue to build these each time I build while still satisfying xcodebuild?
You can add any number of targets (iOS app, static lib, contole app, etc) into same project.
Then you should create another target -
Then you have options:
3.1 Go to scheme settings for aggregate target and add other targets:
where you can specify actions you want to perform on certain target
3.2 You may pick aggregate target and go to build settings and add other targets as a dependencies for this target.
Option 3.1 seems to be the one you need: you can add as many targets as you wish to be build. And you can specify another target for running.
So you'll have something like:
targets:
target 1 - iOS app
target 2 - other app
target 3 - other app
target 4 - aggregate target
scheme configuration for target 4
build section:
target 1
target 2
target 3
run section:
executable: target 1 (iOS app)
Once this is completed you may use your scheme to do builds
xcodebuild -scheme your_scheme [...other options...] archive
UPDATE
You can skip creation of aggregate target.
You can directly create new scheme and to the configuration you want without involving aggregate target.
UPDATE 2
Make sure to share your scheme to be able to keep it in source control.
UPDATE 3
The option w/o aggregate target is more preferable way to achieve this in case if your targets are not depend on each other directly (as far as I understand you). This is the main purpose for schemes.
A scheme is a collection of settings that specify which targets to
build, what build configuration to use, and the executable environment
to use when the product specified by the target is launched. When you
open an existing project (or create a new one), Xcode automatically
creates a scheme for each target.
I created a few test cases and they all passed... That's because they are not being run.
From Xcode, I get:
Test Suite 'All tests' started at...
Test Suite 'All tests' finished at...
Executed 0 tests, with 0 failures (0 unexpected) in 0.00 seconds
The project (and unit test classes) build successfully.
All my test classes have MyApp_appTests as Target Membership selected. Production classes have MyApp_app & MyApp_appTests targets selected.
I verified the MyApp_appTests Target Build Settings (Bundle Loader & Test Host).
Bundle Loader (Debug): $(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp
Test Host (Debug): $(BUNDLE_LOADER)
I have imported SenTestingKit.framework (through Targets Build Phases "Link Binary With Libraries").
All my tests start with -(void)testThat...
I have also checked a few stackoverflow.com questions:
stackoverflow.com/questions/8632254/xcode-4-2-cant-run-unit-test
stackoverflow.com/questions/3608484/ocunit-tests-not-running-not-being-found
stackoverflow.com/questions/16672616/ocunit-test-cases-not-running
and this post:
twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
I don't know where to look for... Any help is greatly appreciated!
For me worked changing "Wrapper extension" from "octest" to "xctest" in Build Settings for tests target
Xcode 5 now used XCTestCase, not SenTest. Apple is now supporting Unit Testing more directly including their own version of SenTest named XCTestCase. Additionally the UI is much improved, allowing individual tests to be run, a Test Navigator and no longer creating .h test files. Note that the test macros are not renames with an XC prefix.
See the WWDC-13 video 409: "Testing in Xcode 5".
If you use the Xcode 5 template to create the testing environment the project will include a test target and a working (and failing) test.
If you are creating a new test target in Xcode 5+ and planning to use SenTestKit for unit tests, changing the 'Wrapper Extension' build setting of your test target to 'octest' from the default 'xctest' will help execute the test cases.
I had this problem with Xcode 7.3, what worked for me was running the application on the device once and then running the tests.