@@ -5,16 +5,38 @@ package vulpix
5
5
import scala .collection .mutable
6
6
import dotc .reporting .TestReporter
7
7
8
+ /** `SummaryReporting` can be used by unit tests by utilizing `@AfterClass` to
9
+ * call `echoSummary`
10
+ *
11
+ * This is used in vulpix by passing the companion object's `SummaryReporting`
12
+ * to each test, the `@AfterClass def` then calls the `SummaryReport`'s
13
+ * `echoSummary` method in order to dump the summary to both stdout and a log
14
+ * file
15
+ */
8
16
trait SummaryReporting {
17
+ /** Report a failed test */
9
18
def reportFailed (): Unit
19
+
20
+ /** Report a test as passing */
10
21
def reportPassed (): Unit
22
+
23
+ /** Add the name of the failed test */
11
24
def addFailedTest (msg : String ): Unit
25
+
26
+ /** Add instructions to reproduce the error */
12
27
def addReproduceInstruction (instr : String ): Unit
28
+
29
+ /** Add a message that will be issued in the beginning of the summary */
13
30
def addStartingMessage (msg : String ): Unit
31
+
32
+ /** Add a cleanup hook to be run upon completion */
14
33
def addCleanup (f : () => Unit ): Unit
34
+
35
+ /** Echo the summary report to the appropriate locations */
15
36
def echoSummary (): Unit
16
37
}
17
38
39
+ /** A summary report that doesn't do anything */
18
40
final class NoSummaryReport extends SummaryReporting {
19
41
def reportFailed (): Unit = ()
20
42
def reportPassed (): Unit = ()
@@ -25,6 +47,9 @@ final class NoSummaryReport extends SummaryReporting {
25
47
def echoSummary (): Unit = ()
26
48
}
27
49
50
+ /** A summary report that logs to both stdout and the `TestReporter.logWriter`
51
+ * which outputs to a log file in `./testlogs/`
52
+ */
28
53
final class SummaryReport extends SummaryReporting {
29
54
30
55
private val startingMessages = mutable.ArrayBuffer .empty[String ]
0 commit comments