Thanks to visit codestin.com
Credit goes to github.com

Skip to content

v7.2.0 - TestState property wrapper

Choose a tag to compare

@younata younata released this 28 Jul 15:18
· 130 commits to main since this release
v7.2.0

Highlight

You can now use the @TestState property wrapper to automatically deconstruct test variables. For example:

describe("using TestState") {
    @TestState var subject: SomeObject?
}

Is functionally equivalent to:

describe("using TestState") {
    var subject: SomeObject?
    afterEach {
        subject = nil
    }
}

You can also specify an initial value, and TestState will act as an aroundEach: setting the wrapped variable to the value, then setting it to nil at test teardown.

describe("using TestState") {
    @TestState(1) var value: Int?

    it("is already configured") {
        expect(value).to(equal(1))
    }
}

Thanks @CraigSiemens for their contribution!

Automated Release Notes

What's Changed

Full Changelog: v7.1.0...v7.2.0