Debian Codegraph @

junit-jupiter-api/src/main/java/org/junit/jupiter/api/TestReporter.java

raw symbols SCIP
1 /*
2 * Copyright 2015-2024 the original author or authors.
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v2.0 which
6 * accompanies this distribution and is available at
7 *
8 * https://www.eclipse.org/legal/epl-v20.html
9 */
10
11 package org.junit.jupiter.api;
12
13 import static org.apiguardian.api.API.Status.STABLE;
14
15 import java.util.Collections;
16 import java.util.Map;
17
18 import org.apiguardian.api.API;
19
20 /**
21 * Parameters of type {@code TestReporter} can be injected into
22 * {@link BeforeEach @BeforeEach} and {@link AfterEach @AfterEach} lifecycle
23 * methods as well as methods annotated with {@link Test @Test},
24 * {@link RepeatedTest @RepeatedTest},
25 * {@link org.junit.jupiter.params.ParameterizedTest @ParameterizedTest},
26 * {@link TestFactory @TestFactory}, etc.
27 *
28 * <p>Within such methods the injected {@code TestReporter} can be used to
29 * publish <em>report entries</em> for the current container or test to the
30 * reporting infrastructure.
31 *
32 * @since 5.0
33 * @see #publishEntry(Map)
34 * @see #publishEntry(String, String)
35 */
36 @FunctionalInterface
37 @API(status = STABLE, since = "5.0")
38 public interface TestReporter {
39
40 /**
41 * Publish the supplied map of key-value pairs as a <em>report entry</em>.
42 *
43 * @param map the key-value pairs to be published; never {@code null};
44 * keys and values within entries in the map also must not be
45 * {@code null} or blank
46 * @see #publishEntry(String, String)
47 * @see #publishEntry(String)
48 */
49 void publishEntry(Map<String, String> map);
50
51 /**
52 * Publish the supplied key-value pair as a <em>report entry</em>.
53 *
54 * @param key the key of the entry to publish; never {@code null} or blank
55 * @param value the value of the entry to publish; never {@code null} or blank
56 * @see #publishEntry(Map)
57 * @see #publishEntry(String)
58 */
59 default void publishEntry(String key, String value) {
60 this.publishEntry(Collections.singletonMap(key, value));
61 }
62
63 /**
64 * Publish the supplied value as a <em>report entry</em>.
65 *
66 * <p>This method delegates to {@link #publishEntry(String, String)},
67 * supplying {@code "value"} as the key and the supplied {@code value}
68 * argument as the value.
69 *
70 * @param value the value to be published; never {@code null} or blank
71 * @since 5.3
72 * @see #publishEntry(Map)
73 * @see #publishEntry(String, String)
74 */
75 @API(status = STABLE, since = "5.3")
76 default void publishEntry(String value) {
77 this.publishEntry("value", value);
78 }
79
80 }