Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for Xcode 12 #1

Merged
merged 1 commit into from
Nov 14, 2020
Merged

Updates for Xcode 12 #1

merged 1 commit into from
Nov 14, 2020

Conversation

devandanger
Copy link
Contributor

@devandanger devandanger commented Oct 18, 2020

I was playing with some function builder use cases and I really liked the idea of this package.
If you're interested I gave it a bit of TLC.

Corrected what I think might have been is a breaking language construct between Xcode 12 and 11 (or whatever those swift versions are exactly.

I also just made the access modifiers more consistent.

I do not know if this works correctly in Xcode 11.x, but I'm not sure if that's a guarantee regardless based on where function builders are currently in the language design.

@devandanger
Copy link
Contributor Author

@q231950 - Thoughts on this?

@q231950
Copy link
Owner

q231950 commented Nov 14, 2020

Hi @devandanger, thanks & I'll have a look later today : )

@q231950
Copy link
Owner

q231950 commented Nov 14, 2020

First of all, sorry for noticing this late, I only got a notification on my phone with the @-mention 😬

This is fantastic @devandanger, thank you so much! And it's great that you had a look at the library. I used it a bit in a private project and I noticed that sometimes it was a bit tedious (and one might also question the subclassing of Step<Context>) to
create steps. In that project I created a GeneralStep where you can do anything with a title so that it appears in the test result view of Xcode:

Given {
    GeneralStep("I log in") {
        // some function that is defined in my test case
        self.login(name: "John Doe", login: "123456789", password: "***", library: "The New York Public Library")
    }
}

Implementation was quite straightforward to make this possible:

class GeneralStep: Step<Context> {
        let content: (() -> ())?
        let contentWithContext: ((_ context: inout Context) -> ())?
        let _title: String

        convenience init(_ title: String, contentWithContext: ((_ context: inout Context)->())? = nil) {
            self.init(title, contentWithContext: contentWithContext, content: nil)
        }

        convenience init(_ title: String, content: (()->())? = nil) {
            self.init(title, contentWithContext: nil, content: content)
        }

        init(_ title: String, contentWithContext: ((_ context: inout Context)->())?, content: (()->())?) {
            self.content = content
            self.contentWithContext = contentWithContext
            self._title = title
        }

        override var title: String {
            _title
        }

        override func execute(in context: inout Context) {
            content?()
            contentWithContext?(&context)
        }
    }

I think I will add this to the package soon, in case you're interested.

@q231950 q231950 merged commit 0fe1b7a into q231950:master Nov 14, 2020
@devandanger
Copy link
Contributor Author

No worries! thanks for merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants