Swift testing support in Swift Playgrounds

With XCTest you were able to tun tests with:

MyTestCase.defaultTestSuite.run()

How can we use the new testing framework with Swift Playgrounds?

Answered by DTS Engineer in 798784022

Swift Playgrounds doesn't support Swift Testing and XCTest. Please file a suggestion if you would like Apple to consider adding such a feature. To file your suggestion, use Feedback Assistant then post the Feedback number here.

Open the .swiftpm package and there is a Package.swift file within. It says not to edit it, but you can. Add test targets like you would any vanilla Swift package. Any tests you add will be picked up by the Xcode test explorer and run that way.

Swift Playgrounds doesn't support Swift Testing and XCTest. Please file a suggestion if you would like Apple to consider adding such a feature. To file your suggestion, use Feedback Assistant then post the Feedback number here.

Swift testing support in Swift Playgrounds
 
 
Q