How to run `xctest` bundle - and how to add `entitlement` to a test target?

I am writing a SPM based project for MacOS. In this project? I need to access MacOS Keychain.

I am write a swift test built by SPM testTarget(). I can see it generates a bundle ./.build/x86_64-apple-macosx/debug/MyProjectTests.xctest with an executable:


% file ./.build/x86_64-apple-macosx/debug/MyProjectPackageTests.xctest/Contents/MacOS/MyProjectPackageTests

./.build/x86_64-apple-macosx/debug/MyProjectPackageTests.xctest/Contents/MacOS/MyProjectPackageTests: Mach-O 64-bit bundle x86_64

This bundle file cannot be executed. How can I execute its tests?

I tried with xcodebuild test-without-building -xctestrun ./.build/x86_64-apple-macosx/debug/MyProjectPackageTests.xctest -destination 'platform=macOS' without any chance.

Obviously the next question is can I 'simply' add entitlement to this bundle with codesign to fix my entitlement error. My hope being whether I can directly execute *.xctest bundle, signing this bundle would solve my issue.

My error when running the test is A required entitlement isn't present.