Skip to content

Instantly share code, notes, and snippets.

@finestructure
Last active November 28, 2018 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save finestructure/d8b9098e7ba8ecb505c24db5684c7744 to your computer and use it in GitHub Desktop.
Save finestructure/d8b9098e7ba8ecb505c24db5684c7744 to your computer and use it in GitHub Desktop.
Stencil file to autogenerate swift package manager linux tests with Sourcery
import XCTest
{{ argument.testimports }}
// swiftlint:disable trailing_comma
{% for type in types.classes|based:"XCTestCase" %}
{% 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.classes|based:"XCTestCase" %}{% 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