xcode 8 shows 0% code coverage when running xctest uitests using xcodebuild - code-coverage

xcode 8 shows 0 code coverage when running xctest uitests using xcodebuild, however when running from xcode the coverage details are shown.
I tried adding unittests as suggested in below stackoverflow question, however that too does not help when running the uitest's using xcodebuild
UI Test Case not show code coverage.
below stackoverflow question seem's to say that code coverage cannot be obtained for uitest's , but my question is how is xcode able to show the code coverage for uitest's
Xcode 7.3.1 UITests Code Coverage always at 0%

Related

Unit test not running on IOS swift 5

I'm implementing unit test in Xcode 13 (13A233). I wrote simple test but my xcode fails running test on this project. On other projects it's running fine. It produces an error
Assertions: System: Test runner never began executing tests after launching. If you believe this error represents a bug, please attach the result bundle at /Users/apple/Library/Developer/Xcode/DerivedData/MunchON-eeidlzwuounsfvbrmieuosqzpsih/Logs/Test/Test-MunchON (Staging)-2021.10.05_11-35-54-+0500.xcresult
I'm unable to resolve this issue. Other questions that i have checked already:
http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
Xcode 4.2, can't run unit test
OCUnit tests not running / not being found
OCUnit test cases not running
Try deleting DerivedData
Open Xcode > Preferences > Locations
Click on the arrow to open DerivedData folder
Delete all from DerivedData folder
Reopen Xcode project
P.S. DerivedData contains cached data such that indexed files etc
FYI It is safe
I had a similar problem and solved it by checking the "Allow testing Host Application APIs" option in the test target.

Why is the code coverage value of fastlane xcov different from Xcode's value for the same scheme?

When I run my tests inside Xcode the code coverage is 10.3%. When running fastlane run xcov for the same scheme the code coverage is 17.17%. The xcov html file shows the same files with the same coverage percentages, only the total coverage is incorrect. How can this be?
I've had the same problem and it turned out that the Xcode versions were not the same. I updated Fastlane's Xcode version to the one I'm using locally and the coverage is the same

Unit tests not started with Xcode 5 and jenkins

I've set up jenkins on my local machine. Than I created a sample app with one failing and one succeeding unit test. When I issue the following command in the terminal
xcodebuild -scheme 'SampleWithTest' -sdk iphonesimulator7.0
-destination platform='iOS Simulator',OS=7.0,name='iPhone Retina (3.5-inch)' clean test
than it clean build the project, starts the simulator and makes the tests. This is how it should work.
When I run the same command via jenkins, it clean builds the project and ends with ** TEST SUCCEEDED ** without starting the simulator or print out the test results. Jenkins just fakes, that the tests was successful.
I test it on my local machine. Nothing headless, remote, source control, slave, code signing or whatever could make any trouble.
The Jenkins Xcode Plugin has not been updated to work with Xcode 5 and the XCTest framework. See this issue. Jenkins and the Xcode Plugin do not understand XCTest output.
Additionally, Xcode 5 changed how Xcode interacts with the simulator and devices when running tests. While there is something like a "headless mode" now for the simulator, access to that functionality isn't available to the Xcode plugin. This means that in some cases, it looks to the Xcode plugin as if the tests run and exit immediately, which is not accurate.
Xcode is known to be pretty tricky to setup with Jenkins, Travis or other non-Apple CI solutions.
Unit Tests support is even worse so you should try using xctool instead.
Related blog entry here.

iOS: Run a single unit test from the command line

I've been trying to find a way to run a single iOS unit test among multiple tests with the command line on an iOS device.
Here is what I've found thus far...
I can use xcodebuild test [options] to build & run every tests.
Found a tool called xctest in /Applications/Xcode.app/Contents/Developer/usr/bin. I've looked up in the man page and it is possible to run a single test. When I try using it, I get an error stating that I'm using x86_64 architecture and then a posix error pops after. This seems to indicate that it might be the xctest for Mac OS X apps.
Found another xctest in for the iPhone Simulator.. but I want to run it on a iOS device
I know that it is possible to select the tests I wish to run in a scheme, but this is problematic since I would need a very skillful & patient monkey to manually do this in a build system.
By the way, I am not using Apple's own Continuous Integration system with bots and using it is out of question because another build system is used for every other platform.
My question is: How can I run a single unit test (XCTest) from the command line with build automation in mind?
P.S: I don't have any code signing issues.
Try using xctool which can run tests on devices https://github.com/facebook/xctool

UI automation error using iOS 5.1 target

I use Instruments 4.3 with UI automation tool for sometime successfully.
Recently I upgraded my target iPhone4 to iOS 5.1 and UI automation is now giving following error :"An error occurred while trying to run the script" for the moment a script is started, no further info than that.
Even when Instruments is running independently from Xcode the problem is still their, also when "run on record" is ticked but no script is selected.
I even reinstalled Xcode 4.3.1 but without success.
Runs fine on simulator and previous iOS version though.
If anyone encountered this issue and has a solution, please reply.
Thanks,

Resources