Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stencil file to autogenerate swift package manager linux tests with Sourcery
import XCTest
{{ argument.testimports }}
// swiftlint:disable trailing_comma
{% for type in types.implementing.LinuxTesting %}
{% if not type.annotations.disableTests %}extension {{ type.name }} {
static var allTests: [(String, ({{ type.name }}) -> () throws -> Void)] = [
{% for method in type.methods %}
{% if method.parameters.count == 0 and method.shortName|hasPrefix:"test" %}
("{{ method.shortName }}", {{ method.shortName }}),
{% endif %}
{% endfor %}]
}
{% endif %}{% endfor %}
XCTMain([
{% for type in types.implementing.LinuxTesting %}{% if not type.annotations.disableTests %} testCase({{ type.name }}.allTests),
{% endif %}{% endfor %}])
// swiftlint:enable trailing_comma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment