SwiftPM not generating testing scaffold when -type=executable

Hi everyone,

I notice that when I use SPM to generate the scaffold for an executable:
swift package init --type=executable
that not test target is added to Package.swift.

Is this intended behaviour? And if so, what is the rationale?

I for one tend to always add a test target as the first thing I do after running the swift package init command, as I always need tests in any project I create. This always takes me some time to copy/paste code from another Package.swift file. And usually a couple of tries before I get the syntax and folder structure correct. Personally, I would expect the default behaviour to be to create a testtarget and tests folder similar as for a generic package.

KR Maarten

This was previously discussed in "Update to swift package init templates".

I read that discussion, but can't find the motivation for getting rid of tests in the executable template.

Also, do we still feel that getting rid of tests is a good idea? Especially as a simple, interactive way of adding a test target has not materialized yet.

3 Likes