|
37 | 37 | import org.junit.jupiter.api.io.TempDir; |
38 | 38 | import org.junit.jupiter.params.ParameterizedTest; |
39 | 39 | import org.junit.jupiter.params.provider.ValueSource; |
| 40 | +import org.junit.platform.commons.util.ExceptionUtils; |
40 | 41 | import org.junit.platform.engine.TestEngine; |
41 | 42 | import org.junit.platform.engine.UniqueId; |
| 43 | +import org.junit.platform.engine.reporting.FileEntry; |
42 | 44 | import org.junit.platform.engine.reporting.ReportEntry; |
43 | 45 | import org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine; |
44 | 46 | import org.junit.platform.tests.process.ProcessResult; |
@@ -78,10 +80,17 @@ void restoreSystemPrintStreams() { |
78 | 80 | void writesValidXmlReport(@TempDir Path tempDirectory) throws Exception { |
79 | 81 | var engine = new DemoHierarchicalTestEngine("dummy"); |
80 | 82 | engine.addTest("failingTest", "display<-->Name 😎", (context, descriptor) -> { |
81 | | - var listener = context.request.getEngineExecutionListener(); |
82 | | - listener.reportingEntryPublished(descriptor, ReportEntry.from("key", "value")); |
83 | | - System.out.println("Hello, stdout!"); |
84 | | - System.err.println("Hello, stderr!"); |
| 83 | + try { |
| 84 | + var listener = context.request.getEngineExecutionListener(); |
| 85 | + listener.reportingEntryPublished(descriptor, ReportEntry.from("key", "value")); |
| 86 | + listener.fileEntryPublished(descriptor, FileEntry.from( |
| 87 | + Files.writeString(tempDirectory.resolve("test.txt"), "Hello, world!"), "text/plain")); |
| 88 | + System.out.println("Hello, stdout!"); |
| 89 | + System.err.println("Hello, stderr!"); |
| 90 | + } |
| 91 | + catch (Throwable t) { |
| 92 | + throw ExceptionUtils.throwAsUncheckedException(t); |
| 93 | + } |
85 | 94 | fail("failure message"); |
86 | 95 | }); |
87 | 96 |
|
@@ -130,6 +139,11 @@ void writesValidXmlReport(@TempDir Path tempDirectory) throws Exception { |
130 | 139 | </data> |
131 | 140 | </attachments> |
132 | 141 | </e:reported> |
| 142 | + <e:reported id="2" time="${xmlunit.isDateTime}"> |
| 143 | + <attachments> |
| 144 | + <file time="${xmlunit.isDateTime}" path="../test.txt" mediaType="text/plain" /> |
| 145 | + </attachments> |
| 146 | + </e:reported> |
133 | 147 | <e:reported id="2" time="${xmlunit.isDateTime}"> |
134 | 148 | <attachments> |
135 | 149 | <output time="${xmlunit.isDateTime}" source="stdout"><![CDATA[Hello, stdout!]]></output> |
|
0 commit comments