xcodebuild test-without-building cannot find baseline file

So I am trying to use test without building for my perf test.

I use below command to build for testing:

xcodebuild build-for-testing -destination 'platform=iOS Simulator,name=iPhone 12 Pro' -project MeasuringInTests.xcodeproj -scheme MeasuringInTests 

and it succeeds

now start testing:

xcodebuild test-without-building -destination "platform=iOS Simulator,name=iPhone 12 Pro" -xctestrun /Users/lx/Library/Developer/Xcode/DerivedData/MeasuringInTests-adylpmhgxgvhbmfsacjgebueadzk/Build/Products/MeasuringInTests_iphonesimulator14.5-x86_64.xctestrun

however for every test case it throws:

Test Suite 'MeasuringInTestsUITests' started at 2021-08-04 19:10:14.708
Test Case '-[MeasuringInTestsUITests.MeasuringInTestsUITests testCalculateWithClockMetric]' started.
  t =   0.00s Start Test at 2021-08-04 19:10:14.709
Error while reading test baseline file: "The file “9A6EEBD5-A75D-4D0E-9ED2-2ACCBC1BEE47.plist” couldn’t be opened because there is no such file." at path: "/Users/lx/Downloads/MeasuringInTests-master/__TESTHOST__/PlugIns/MeasuringInTestsUITests.xctest/xcbaselines/9A6EEBD5-A75D-4D0E-9ED2-2ACCBC1BEE47.plist"2021-08-04 19:10:15.158590+0800 MeasuringInTestsUITests-Runner[56077:5970055] Running tests...

Restarting after unexpected exit, crash, or test timeout in MeasuringInTestsUITests.testCalculateWithClockMetric(); summary will include totals from previous launches.

I have no idea why the path became "/Users/lx/Downloads/MeasuringInTests-master/__TESTHOST__/PlugIns/MeasuringInTestsUITests.xctest

nor do I know how to fix this.

Are there any variables I should specify to generate the baseline file for xctestrun files?

because in the xctestrun file, it shows:

  "MeasuringInTestsUITests": {
    "BaselinePath": "__TESTBUNDLE__/xcbaselines/9A6EEBD5-A75D-4D0E-9ED2-2ACCBC1BEE47.plist",
    "BlueprintName": "MeasuringInTestsUITests",

Please help how to fix this.

directly using xcodebuild test seems totally fine, but I do want to take advantage of test without building.

Post not yet marked as solved Up vote post of Wingzero Down vote post of Wingzero
1.8k views