Skip to content

Commit

Permalink
Introduce SwiftLintTestCase
Browse files Browse the repository at this point in the history
To consistently set up rules before tests
  • Loading branch information
jpsim committed Apr 25, 2023
1 parent 165172e commit 4c04cda
Show file tree
Hide file tree
Showing 93 changed files with 342 additions and 359 deletions.
3 changes: 1 addition & 2 deletions .sourcery/GeneratedTests.stencil
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
@_spi(TestHelper)
@testable import SwiftLintFramework
import SwiftLintTestHelpers
import XCTest

// swiftlint:disable:next blanket_disable_command
// swiftlint:disable file_length single_test_class type_name

{% for rule in types.structs %}
{% if rule.name|hasSuffix:"Rule" %}
class {{ rule.name }}GeneratedTests: XCTestCase {
class {{ rule.name }}GeneratedTests: SwiftLintTestCase {
func testWithDefaultConfiguration() {
verifyRule({{ rule.name }}.description)
}
Expand Down
7 changes: 7 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ file_name:
- GeneratedTests.swift
- TestHelpers.swift

balanced_xctest_lifecycle: &unit_test_configuration
test_parent_classes:
- SwiftLintTestCase
- XCTestCase
empty_xctest_method: *unit_test_configuration
single_test_class: *unit_test_configuration

function_body_length: 60
type_body_length: 400

Expand Down
3 changes: 1 addition & 2 deletions Tests/ExtraRulesTests/ExtraRulesTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@testable import SwiftLintFramework
import SwiftLintTestHelpers
import XCTest

final class ExtraRulesTests: XCTestCase {
final class ExtraRulesTests: SwiftLintTestCase {
func testWithDefaultConfiguration() {
for ruleType in extraRules() {
verifyRule(ruleType.description)
Expand Down
Loading

0 comments on commit 4c04cda

Please sign in to comment.