Cannot get unit tests stats due to missing test logs either in derived data or result bundle path
I'd like to gather the test coverage statistics for a given target in a project. The Xcode version that I use is 12.4. I did run tests for a project via xcodebuild command:
$ xcodebuild test -scheme Demo -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11 Pro,OS=14.4' -resultBundlePath ~/Demo/result
According to the blog post mentioned in the README file, there should be .xcactivitylog log generated at the result bundle path, however, with Xcode 12.4, it is not. There's a .xcresult file instead.
I also checked the derived data and same results.
I tried to simply parse the build activity log, but no data about unit tests has been found:
$ xclogparser parse --project Demo --reporter html
Could you please help me to figure out the way to get the unit tests coverage stats? 🙏
I will gladly update the documentation if needed 😊
Hi Daniel!
I tried Xcode 12.4 behaviour for a brand new project and .xcactivitylog files are placed in the derived data.
To customize that dir, you can append -derivedDataPath, like
xcodebuild test -scheme Demo -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11 Pro,OS=14.4' -resultBundlePath ~/Demo/result -derivedDataPath ~/Demo/DerivedData
and the loot at ~/Demo/DerivedData/{{Project}}/Logs/Build/.
If you call xcodebuild test and your DerivedData contains all products required for the test, indeed the *.xcactivitylog is in a lightweight format. To get a full build log, please try calling xcodebuild clean test... or xcodebuild clean build-for-testing ...
Hey Bartosz! Thank you for the response.
I prepared a vanilla Swift iOS app project, cleaned up the derived data and run xcodebuild clean test ..., but still no unit tests coverage information from a parse command (I tired different reporters).
Below some screenshots how the output looks like:
Could you please provide your steps in order to get the unit tests coverage report via xclogparser? 🙏
XCLogParser can capture building logs (compilation steps, errors, warnings etc.) but not unit tests results like code coverage. When you run tests in Xcode or xcodebuild the only generated .xcactivitylog file contains a summary of all steps in the build-for-testing phase (you have it generated in the Build dir).
XCLogParser can capture building logs (compilation steps, errors, warnings etc.) but not unit tests results like code coverage.
That's interesting. According to the README file:
XCLogParser can give a lot of insights in regards to build times for every module and file in your project, warnings, errors and unit tests results.
Apparently, I miss-understood "unit tests results" phrase then. Maybe we could avoid ambiguity and tweak the documentation to clearly point out what type of unit tests results are available? 😊
@ecamacho, do you remember what did we mean by "rests results" in a Readme file?
bump on this - I was also under the impression xclogparser can parse unit tests results or maybe XCLogParser expect xcodebuild test generate a .xcactivitylog file at some point? and the newwer Xcode no longer does that?
@ecamacho Do you have any knowledge about this issue? Thanks