-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add UIKit screenshot tests for layout's Spacer
#1542
Add UIKit screenshot tests for layout's Spacer
#1542
Conversation
534935c
to
320d8d7
Compare
/** | ||
* An abstract base class for hosting Kotlin test classes in Swift projects. | ||
* | ||
* Subclasses must override `initTest(name:)` to create instances of `KotlinType`. | ||
*/ | ||
open class KotlinHostingXCTestCase<KotlinTest>: KotlinHostingXCTestCaseHelper where KotlinTest: NSObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here be crimes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍿
final class UIViewSpacerTestHost: KotlinHostingXCTestCase<UIViewSpacerTest> { | ||
override class func initTest(name: String) -> UIViewSpacerTest { | ||
return UIViewSpacerTest(callback: Callback(named: name)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is 👨🍳💋
This adds the start of a new setup for hosting Kotlin tests within an iOS project so that we can use a Swift screenshot testing library. For now you have to prefix your test functions with "test" and any before/after-annotated functions need to be named "setUp" and "tearDown" (very JUnit 3). We also do not support anything JVM-specific like rules or parameterization for now.
320d8d7
to
3d4411e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
/** | ||
* An abstract base class for hosting Kotlin test classes in Swift projects. | ||
* | ||
* Subclasses must override `initTest(name:)` to create instances of `KotlinType`. | ||
*/ | ||
open class KotlinHostingXCTestCase<KotlinTest>: KotlinHostingXCTestCaseHelper where KotlinTest: NSObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍿
|
||
private static func createTestMethod(target: KotlinTest, selector: Selector) { | ||
let block: @convention(block) () -> Void = { | ||
if target.responds(to: #selector(setUp)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooooh
if target.responds(to: #selector(setUp)) { | ||
target.perform(#selector(setUp)) | ||
} | ||
defer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat
This adds the start of a new setup for hosting Kotlin tests within an iOS project so that we can use a Swift screenshot testing library. For now you have to prefix your test functions with "test" and any before/after-annotated functions need to be named "setUp" and "tearDown" (very JUnit 3). We also do not support anything JVM-specific like rules or parameterization for now.
Refs #1343