run Xcode project tests from terminal - xcode

I am quite curious to know if there is a way to achieve the same that you get, when in Xcode you press cmd-u (or select Test from the menu).
I am writing some UI tests for an application, and would love to automate the whole thing.
So far, any attempt to automate via applescript has been quite unsuccessful (I told myself how hard it is to simulate 2 button pressed...); so I thought that maybe there is a proper way to just run the command line commands and have the simulator to pop and run the tests, like it does in Xcode.
Altho if this function was known, I would find something online, but it seems that there is no way to simulate the test command via console.
Am I missing something?

Have you checked out the xcodebuild command?
The man page says:
buildaction ...
Specify a build action (or actions) to perform on the target. Available build actions are:
test Test a scheme from the build root (SYMROOT). This requires specifying a scheme.
So, perhaps that will do what you want.

Related

Confirming compile time scripts execution in Xcode

I am downloading data from a remote server using curl in Build Phases > Run Script. Downloading takes 5-15s, not that much, but multiple times a day it consumes considerable time. Is there a better way to skip a script than commenting it out? Ideally, it would be some kind of confirmation at compile time (e.g Do you really need to download X? y/n).
You can’t make the run script interactive in the console as far as I know. But you can use a shell conditional with an AppleScript interactive dialog, because AppleScript itself blocks while dialog is shown. See for example https://cantina.co/adding-interactivity-to-the-xcode-build-process/.
However, introducing uncertainty into a build is dangerous. Plus you’d never be able to automate the build. In my view you’d be better off flipping a custom build setting / environment variable.

Rerun failed unit test - Xcode XCTest

When I run my XCTests, I'd like to automatically rerun, once, any integration (unit/ui) test that fails. Is this possible?
This would be done in the same test, without having to hit 'run' again on my tests, or any part of my tests. I'm running all my tests from the command line.
I am doing UI tests that use the network to make calls to the server. If there is a significant server problem, the test will/should fail and report an error. However, if it is only a temporary problem with the request, it would be nice to rerun the test automatically and see if it passes. Also, with the current state of Xcode UI testing there are some occasional problems where it will crash for an obscure reason, and it would be nice to rerun the test automatically to see if it passes the second time.
It would be especially nice if it could output what happened, i.e. "The test failed the first time, because of failure getting refreshed snapshot, but passed the second time"
You can now do this in Xcode without any scripts.
Press ⌘ + 6 or select the test assistant view.
Filter for failed tests
Select tests, right click and choose Run x test methods > Run in all classes
(optional) If you want to run the same tests again press ⌃ + ⌥ + ⌘ + G for a quick way to run them right away.
Task list to accomplish this without fastlane and with granular test reruns
create a script to rerun the test and capture the list of failed tests, then rerun the tests using the -only-testing:TEST-IDENTIFIER flag of xcodebuild.
parse the resultBundle or .xcresult to find the failed tests
write code to erase the device or simulator executing the tests
reboot the device if it is a real one to clear any possible dialogs
use XCAttachment to collect things you care about, like app logs
use xchtmlreport to generate a nice webpage from the results bundle with your snapshots and attachments.
Fastlane can make it possible here is the awesome blog post regarding same
Stabilizing the CI By Re-runing Flaky iOS XCUI Tests

Explore and debug vim script

I would like to dynamically debug a vim script. My current workflow is that I have the autoload plugin opened on a tmux pannel and the running application on the other pannel. I also set a tail -f vim.log and I launched vim with vim -V15vim.log. My goal is to monitor the execution of the plugin by adding plenty of echom.
Actually I was expecting something more useful that what I actually got.
I need to restart vim everytime I add a new echom
Nothing really useful is displayed on the log file vim.log
This method is obviously not the right one
I also tried to add breakpoints with breakadd func myfunc#test but it is not really working because the debugger windows interfers with the main window and change the way the plugin I am debuging behave.
How to improve my vim-script debug workflow?
HINT
I am actually trying to debug the vim-multiple-cursor plugin which does not work with a column block selection and virtualedit enabled. I would like to fix it.
:breakadd is the most powerful tool, but yes, its output and interaction may interfere with certain plugin actions, and trigger additional autocmds. It may help if you specify the optional [lnum] offset to only stop executing inside the function.
I need to restart vim everytime I add a new echom
It should be enough if you just :source the changed plugin script again. Scripts inside ~/.vim/plugin/ usually employ a multiple inclusion guard that you need to work around, though. My ReloadScript plugin can help with that.
Alternatively, the Decho plugin might offer a different approach worth looking at.

Build a installation wrapper for my application

SO I have a application that is a simple installer that use a flag at the end of it like so:
CLIENTSETUP.EXE /BLAH
My goal is to build a install wrapper for it so I don't always have to open a command prompt to run it. I want to be able to just double click to run it.
I'm not exactly sure where to go from here and what to use. Someone told me C# would be there best one to use but maybe there is a easier way?

xcode and ad-hoc-distribution: can i bring xcode to automatically make an .ipa?

can i make, that when compiling in the adhoc-profile, i made for xcode, pack it into a zip complaining to itunes or an ipa, give it an automatic name (optional ... appname_date_time.zip) and copy it to a network-path ?
so, what is really my problem: i think i understood, that in a past-build-phase i can run a shell-script. but i haven´t done many shell-scripting now. can i zip on osx with the shell and for this case in a simple way ?
and can i let the message "no provisioned iphone connected" be gone ?
why ?
i want, that some company-internal people can load my software without email-spamming on each new release.
ok, build and archive builds at least the .ipa automatically. the rest might be just a second click and a script. so if no one has a more elegant solution, this is enough
Check out the BetaBuilder gem - https://github.com/lukeredpath/betabuilder. It worked about 90% of the way for me - I had to re-route its guts a bit to make it work, but my fork (https://github.com/dts/betabuilder) works for me. Hopefully, you can cobble together a solution for you (it was worth the effort for me!)
You can automate this, but need to get after the code signing, which is behind the last build phase you can add to Xcode. So the solution is creating a new aggregate target and define the shell script in there.
Here is an example of the whole process including a readme file on how to set it up: https://github.com/TheRealKerni/HockeyKit/tree/develop/client/iOS/Beta%20Automatisation

Resources