-
Notifications
You must be signed in to change notification settings - Fork 128
Show the number of test cases that ran at the end of a test #972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
14184b1
a1f7b4b
928f67b
2a796ec
16a997e
ea309da
4592e06
4cf3306
46d4910
701506c
9616b98
8f61da7
5c52756
a5bac97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,9 @@ extension Event { | |
|
|
||
| /// The number of known issues recorded for the test. | ||
| var knownIssueCount = 0 | ||
|
|
||
| /// The number of test cases for the test. | ||
| var testCasesCount: Int = 0 | ||
| } | ||
|
|
||
| /// Data tracked on a per-test basis. | ||
|
|
@@ -281,6 +284,10 @@ extension Event.HumanReadableOutputRecorder { | |
| testData.issueCount[issue.severity] = issueCount + 1 | ||
| } | ||
| context.testData[id] = testData | ||
|
|
||
| case .testCaseStarted: | ||
| let test = test! | ||
| context.testData[test.id.keyPathRepresentation]?.testCasesCount += 1 | ||
|
|
||
| default: | ||
| // These events do not manipulate the context structure. | ||
|
|
@@ -366,18 +373,23 @@ extension Event.HumanReadableOutputRecorder { | |
| let testData = testDataGraph?.value ?? .init(startInstant: instant) | ||
| let issues = _issueCounts(in: testDataGraph) | ||
| let duration = testData.startInstant.descriptionOfDuration(to: instant) | ||
| let testCasesCount = if verbosity >= 2 && test.isParameterized { | ||
|
||
| " with \(testData.testCasesCount.counting("test case"))" | ||
| } else { | ||
| "" | ||
| } | ||
| return if issues.errorIssueCount > 0 { | ||
| CollectionOfOne( | ||
| Message( | ||
| symbol: .fail, | ||
| stringValue: "\(_capitalizedTitle(for: test)) \(testName) failed after \(duration)\(issues.description)." | ||
| stringValue: "\(_capitalizedTitle(for: test)) \(testName)\(testCasesCount) failed after \(duration)\(issues.description)." | ||
| ) | ||
| ) + _formattedComments(for: test) | ||
| } else { | ||
| [ | ||
| Message( | ||
| symbol: .pass(knownIssueCount: issues.knownIssueCount), | ||
| stringValue: "\(_capitalizedTitle(for: test)) \(testName) passed after \(duration)\(issues.description)." | ||
| stringValue: "\(_capitalizedTitle(for: test)) \(testName)\(testCasesCount) passed after \(duration)\(issues.description)." | ||
| ) | ||
| ] | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -178,6 +178,44 @@ struct EventRecorderTests { | |||||||||||||||||||||
| .first != nil | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @available(_regexAPI, *) | ||||||||||||||||||||||
| @Test( | ||||||||||||||||||||||
| "number of arguments based on verbosity level at the end of test run", | ||||||||||||||||||||||
|
||||||||||||||||||||||
| arguments: [ | ||||||||||||||||||||||
| ("f()", #".* Test f\(\) failed after .*"# , 0), | ||||||||||||||||||||||
| ("f()", #".* Test f\(\) failed after .*"# , 2), | ||||||||||||||||||||||
| ("d(_:)", #".* Test d\(_:\) with .+ test cases passed after.*"# , 2), | ||||||||||||||||||||||
| ("PredictablyFailingTests", #".* Suite PredictablyFailingTests failed after .*"# , 1), | ||||||||||||||||||||||
| ("PredictablyFailingTests", #".* Suite PredictablyFailingTests failed after .*"# , 2), | ||||||||||||||||||||||
|
||||||||||||||||||||||
| ("f()", #".* Test f\(\) failed after .*"# , 0), | |
| ("f()", #".* Test f\(\) failed after .*"# , 2), | |
| ("d(_:)", #".* Test d\(_:\) with .+ test cases passed after.*"# , 2), | |
| ("PredictablyFailingTests", #".* Suite PredictablyFailingTests failed after .*"# , 1), | |
| ("PredictablyFailingTests", #".* Suite PredictablyFailingTests failed after .*"# , 2), | |
| ("f()", #".* Test f\(\) failed after .*"#, 0), | |
| ("f()", #".* Test f\(\) failed after .*"#, 2), | |
| ("d(_:)", #".* Test d\(_:\) with .+ test cases passed after.*"#, 2), | |
| ("PredictablyFailingTests", #".* Suite PredictablyFailingTests failed after .*"#, 1), | |
| ("PredictablyFailingTests", #".* Suite PredictablyFailingTests failed after .*"#, 2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can omit the explicit type since this isn't a
publicproperty, to match prevailing style