Skip to content

Commit

Permalink
skipping empty test classes
Browse files Browse the repository at this point in the history
checking for class rather than XCTest to allow subclasses to be parsed properly
  • Loading branch information
valeriomazzeo committed May 17, 2017
1 parent 447d5b2 commit e083990
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions Sources/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func getTestClasses(_ input: ReadableFile) -> TestClasses {

for line in input.lines() {

if line.contains("XCTestCase"), let name = line.subString(between: "class", and: ":")?.trimmingCharacters(in: .whitespaces) {
if line.contains("class"), let name = line.subString(between: "class", and: ":")?.trimmingCharacters(in: .whitespaces) {

classname = name
result[name] = Set()
Expand All @@ -64,7 +64,7 @@ func getTestClassesFromAllTests(_ input: ReadableFile) -> TestClasses {

for line in input.lines() {

if line.contains("XCTestCase"), let name = line.subString(between: "class", and: ":")?.trimmingCharacters(in: .whitespaces) {
if line.contains("class"), let name = line.subString(between: "class", and: ":")?.trimmingCharacters(in: .whitespaces) {

classname = name
result[name] = Set()
Expand Down Expand Up @@ -167,16 +167,11 @@ func checkOnly(testDir: Directory, testFiles: [FilePath]) throws -> Bool {
for testFile in testFiles {
let testClasses = getTestClasses(try testFile.open())

guard !testClasses.values.isEmpty else {
print(" \(path): Skipping, no test classes found.")
continue
}

let allTestsTestClasses = getTestClassesFromAllTests(try testFile.open())

missingTests.merge(with: testClassesDifference(testClasses, declared: allTestsTestClasses))

allTestClassNames.formUnion(Set(testClasses.keys))
allTestClassNames.formUnion(Set(testClasses.flatMap({ $0.value.isEmpty ? nil : $0.key })))
}

// Check for missing test classes in LinuxMain.swift
Expand Down

0 comments on commit e083990

Please sign in to comment.