pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
12.11k stars 1.42k forks source link

Swift Testing - Tests should fail with TestStore but aren't failing #3241

Closed omarzl closed 1 month ago

omarzl commented 1 month ago

Description

Running tests with TestStore using Swift Testing aren't failing.

Tested with latest main commit a792049

Checklist

Expected behavior

I am learning about the architecture using the tutorial: https://pointfreeco.github.io/swift-composable-architecture/main/tutorials/meetcomposablearchitecture/

I took the opportunity to try writing the tests with Swift Testing in Xcode 16, but a failing test is not failing.

Code:

struct DemoTests {
    @Test func example() async {
        let store = TestStore(initialState: CounterFeature.State()) {
             CounterFeature()
           }
        await store.send(.incrementButtonTapped) {
           $0.count = 0
         }
         await store.send(.decrementButtonTapped) {
           $0.count = 0
         }
    }
}

@MainActor
final class CounterFeatureTests: XCTestCase {
  func testCounter() async {
        let store = TestStore(initialState: CounterFeature.State()) {
            CounterFeature()
        }
        await store.send(.incrementButtonTapped) {
            $0.count = 0
        }
        await store.send(.decrementButtonTapped) {
            $0.count = 0
        }
    }

}

Output:

image

Expected behaviour: Both tests should fail

Actual behavior

The test using Swift Testing is not failing

Steps to reproduce

No response

The Composable Architecture version information

a792049

Destination operating system

iOS 18

Xcode version information

Version 16.0 beta 3 (16A5202i)

Swift Compiler version information

swift-driver version: 1.111.2 Apple Swift version 6.0 (swiftlang-6.0.0.5.15 clang-1600.0.22.6)

Target: arm64-apple-macosx15.0
Matejkob commented 1 month ago

I believe running tests in swift-testing land is not supported yet. This PR adds support to it: #3229

omarzl commented 1 month ago

Oh great! I only looked at the issues, forgot the prs 😅

mbrandonw commented 1 month ago

Yep that's right, it's hopefully coming soon. There have been multiple complications and set backs while trying to support swift-testing in our libraries and so it has taken a little longer than we hoped. But we are still working on it. 🙂