Unfortunately you might not be able to avoid this, because Xcode’s test action by default compiles your code with the Debug config, while archive is done with Release config.
You can of course try to change this, to e.g. run the tests with the Release config too, but that might cause issues long term.
An alternative solution might be a workflow where you only run Test on Pull Requests, and you only run Archive on Pull Request merge. Something like http://devcenter.bitrise.io/webhooks/trigger-map/#a-very-simple-two-workflow-cicd-setup or http://devcenter.bitrise.io/webhooks/trigger-map/#using-a-branch-to-trigger-the-production-deployment
We use this for our main website (bitrise.io), running tests only on the Pull Requests, but this requires some additional configuration / consideration on your source code hosting service. E.g. we prevent any push to
master by using GitHub protected branches, enforcing that every PR have to pass the tests before merge, as well as that it have to be “up to date” with
master before it could be merged (as well as it have to pass a code review before merge).