Stay Ahead of Bugs: How XCTests Can Keep Your iOS App Leak-Free!
Detect memory leaks in your app using addTeardownBlock and a custom XCTestCase extension.
#Swift #XCTest
https://qualitycoding.org/swift-memory-leak-detection-xctest/
Since XCTest dose not support async expressions in its assert functions I released SwiftAsyncAsserts to fill that gap.
Write more readable testing code for your async APIS in Swift with SwiftAsyncAssert Swift package.
#swift #xctest #asyncawait #unittest
#Swift #SwiftUI #XCTest #SnapshotTesting
I’m having trouble with Pointfreeco’s snapshot testing. Tests run and complete fine, but there’s a delay at the end of the test process. I can’t figure out where it’s coming from or what causes it. Reduced to a very simple fully reproducible example in my environment.
Anyone have any ideas?
https://github.com/pointfreeco/swift-snapshot-testing/issues/752
#swift #swiftui #xctest #snapshottesting
#Swift #XCTest #SnapshotTesting #XcodeCloud
Point-Free has an excellent snapshot-testing library that lets you unit test your view snapshots (screenshots). It does not work with Xcode Cloud out of the box, because test runner environment in Xcode Cloud does not have access to the source repository, which snapshot-testing assumes by default.
Here’s my solution for making snapshot-testing work correctly with Xcode Cloud. https://jaanus.com/snapshot-testing-xcode-cloud/
#swift #xctest #snapshottesting #xcodecloud
#Swift enumerations: How to write #XCTest assertions to verify them? What about associated values? https://qualitycoding.org/unit-test-enumerations-swift/
Cool trick I learned for UI tests in Xcode. You can set "TZ" launch environment value to force the app to use provided time zone. Useful when testing layout that displays formatted dates.
https://developer.apple.com/forums/thread/86951?answerId=263395022#263395022
#iosdev #xctest #uitesting #Swift
#Swift enumerations: How to write #XCTest assertions to verify them? What about associated values? https://qualitycoding.org/unit-test-enumerations-swift/
#Swift enumerations: How to write #XCTest assertions to verify them? What about associated values? https://qualitycoding.org/unit-test-enumerations-swift/
In #XCTest, I declare all test methods as throws because it makes life easier, and there's no penalty. Can I do the same with MainActor at the class level? They're already running on the main thread, so this seems similar.
How can you write #XCTest assertions to verify #Swift optionals, getting the most from failures? #SwiftLang #UnitTests https://qualitycoding.org/unit-test-optionals-swift/
#xctest #swift #SwiftLang #unittests
I don’t know if I’m the person to make it, but I feel like a #Swift package to make doing all of the normal testing things #XCTest doesn’t give you would be pretty amazing.
The equivalent would be how #Rails uses Minitest (by default) but then also adds a bunch of stuff of its own to make testing web apps easy.
FB11933090: Provide option to follow Test Plan order in initializing Test Targets irrespective of "Run in Parallel" status
How do you test a custom test assertion? It depends. Usually, by hand, unless… #SwiftLang #XCTest https://stackoverflow.com/a/74880885/246895
If there's anyone out here who uses the #KIF framework to run UI tests via #XCTest and is using it with #SwiftUI I'd love your input on this issue, of a control that is tappable in practice, and via the Accessibility Inspector, but not in my KIF test: https://github.com/kif-framework/KIF/issues/1271
Sure wish there was a decent way to create parameterized #XCTest unit tests. I've got an array of test data, want to run the same method on each of about ten items and assert that a particular outcome occurs.
Found this approach but too much of a kludge for me:
https://kazaimazai.com/parametrized-xctest-swift/
Not sure whether to just duplicate ten tests, one for each test data item, or to put a for...in in an XCTest and deal with the lack of specificity for failures. Hgn. #Swift #UnitTesting