41
41
import org .itsallcode .io .Capturable ;
42
42
import org .itsallcode .junit .sysextensions .SystemErrGuard ;
43
43
import org .itsallcode .junit .sysextensions .SystemErrGuard .SysErr ;
44
+ import org .junit .jupiter .api .BeforeEach ;
44
45
import org .junit .jupiter .api .Test ;
45
46
import org .junit .jupiter .api .extension .ExtendWith ;
46
47
import org .junit .jupiter .api .io .TempDir ;
@@ -64,6 +65,19 @@ protected String getPackageLocation() {
64
65
return "com/puppycrawl/tools/checkstyle/checks/javadoc/abstractjavadoc" ;
65
66
}
66
67
68
+ /**
69
+ * <p>Configures the environment for each test.</p>
70
+ * <ul>
71
+ * <li>Start output capture for {@link System#err}</li>
72
+ * </ul>
73
+ *
74
+ * @param systemErr wrapper for {@code System.err}
75
+ */
76
+ @ BeforeEach
77
+ public void setUp (@ SysErr Capturable systemErr ) {
78
+ systemErr .captureMuted ();
79
+ }
80
+
67
81
@ Test
68
82
public void testJavadocTagsWithoutArgs () throws Exception {
69
83
final DefaultConfiguration checkconfig = createModuleConfig (TempCheck .class );
@@ -112,7 +126,6 @@ public void testCustomTag() throws Exception {
112
126
113
127
@ Test
114
128
public void testParsingErrors (@ SysErr Capturable systemErr ) throws Exception {
115
- systemErr .capture ();
116
129
final DefaultConfiguration checkConfig = createModuleConfig (TempCheck .class );
117
130
final String [] expected = {
118
131
"4: " + getCheckMessage (MSG_JAVADOC_MISSED_HTML_CLOSE , 4 , "unclosedTag" ),
@@ -135,7 +148,6 @@ public void testWithMultipleChecks() throws Exception {
135
148
136
149
@ Test
137
150
public void testAntlrError (@ SysErr Capturable systemErr ) throws Exception {
138
- systemErr .capture ();
139
151
final DefaultConfiguration checkConfig = createModuleConfig (TempCheck .class );
140
152
final String [] expected = {
141
153
"4: " + getCheckMessage (MSG_JAVADOC_PARSE_RULE_ERROR , 78 ,
@@ -148,7 +160,6 @@ public void testAntlrError(@SysErr Capturable systemErr) throws Exception {
148
160
@ Test
149
161
public void testCheckReuseAfterParseErrorWithFollowingAntlrErrorInTwoFiles (
150
162
@ SysErr Capturable systemErr ) throws Exception {
151
- systemErr .capture ();
152
163
final DefaultConfiguration checkConfig = createModuleConfig (TempCheck .class );
153
164
final Map <String , List <String >> expectedMessages = new LinkedHashMap <>(2 );
154
165
expectedMessages .put (getPath ("InputAbstractJavadocParsingErrors.java" ), asList (
0 commit comments