-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathTestNameExtractorSpec.swift
136 lines (112 loc) · 5.79 KB
/
TestNameExtractorSpec.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//
// TestNameExtractorSpec.swift
// FBSnapshotsViewerTests
//
// Created by Anton Domashnev on 15.08.17.
// Copyright © 2017 Anton Domashnev. All rights reserved.
//
import Quick
import Nimble
@testable import FBSnapshotsViewer
class FailedTestNameExtractorSpec: QuickSpec {
override func spec() {
var subject: TestNameExtractor!
beforeEach {
subject = FailedTestNameExtractor()
}
describe(".extractTestName") {
context("given kaleidoscopeCommandMessage") {
context("with valid line") {
var logLine: ApplicationLogLine!
beforeEach {
logLine = ApplicationLogLine.kaleidoscopeCommandMessage(line: "ksdiff \"/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/reference_testFail@2x.png\" \"/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/failed_testFail@2x.png\"")
}
it("extracts test name") {
expect(try? subject.extractTestName(from: logLine)).to(equal("testFail"))
}
}
context("with invalid line") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.kaleidoscopeCommandMessage(line: "foo/bar")) }.to(throwError())
}
}
}
context("given applicationNameMessage") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.applicationNameMessage(line: "foo/bar")) }.to(throwError())
}
}
context("given fbReferenceImageDirMessage") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.fbReferenceImageDirMessage(line: "foo/bar")) }.to(throwError())
}
}
context("given snapshotTestErrorMessage") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.snapshotTestErrorMessage(line: "foo/bar")) }.to(throwError())
}
}
context("given unknown") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.unknown) }.to(throwError())
}
}
context("given referenceImageSavedMessage") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.referenceImageSavedMessage(line: "bar/bar")) }.to(throwError())
}
}
}
}
}
class RecordedTestNameExtractorSpec: QuickSpec {
override func spec() {
var subject: TestNameExtractor!
beforeEach {
subject = RecordedTestNameExtractor()
}
describe(".extractTestName") {
context("given kaleidoscopeCommandMessage") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.kaleidoscopeCommandMessage(line: "foo/bar")) }.to(throwError())
}
}
context("given applicationNameMessage") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.applicationNameMessage(line: "foo/bar")) }.to(throwError())
}
}
context("given fbReferenceImageDirMessage") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.fbReferenceImageDirMessage(line: "foo/bar")) }.to(throwError())
}
}
context("given snapshotTestErrorMessage") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.snapshotTestErrorMessage(line: "foo/bar")) }.to(throwError())
}
}
context("given unknown") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.unknown) }.to(throwError())
}
}
context("given referenceImageSavedMessage") {
context("with valid line") {
var logLine: ApplicationLogLine!
beforeEach {
logLine = ApplicationLogLine.referenceImageSavedMessage(line: "2017-04-25 21:15:37.107 FBSnapshotsViewerExample[56034:787919] Reference image save at: /Users/antondomashnev/Work/FBSnapshotsViewerExample/FBSnapshotsViewerExampleTests/ReferenceImages_64/FBSnapshotsViewerExampleTests/testRecord@2x.png")
}
it("extracts test name") {
expect(try? subject.extractTestName(from: logLine)).to(equal("testRecord"))
}
}
context("with invalid line") {
it("throws exception") {
expect { try subject.extractTestName(from: ApplicationLogLine.referenceImageSavedMessage(line: "bar/bar")) }.to(throwError())
}
}
}
}
}
}