|
12 | 12 | * See the License for the specific language governing permissions and
|
13 | 13 | * limitations under the License.
|
14 | 14 | */
|
15 |
| -package org.htmlunit; |
| 15 | +package org.htmlunit.junit; |
16 | 16 |
|
17 | 17 | import java.io.ByteArrayOutputStream;
|
18 | 18 | import java.io.OutputStream;
|
19 | 19 | import java.io.PrintStream;
|
| 20 | +import java.util.Optional; |
20 | 21 | import java.util.regex.Pattern;
|
21 | 22 |
|
22 | 23 | import org.apache.commons.lang3.StringUtils;
|
| 24 | +import org.htmlunit.WebDriverTestCase; |
23 | 25 | import org.junit.jupiter.api.extension.AfterEachCallback;
|
24 | 26 | import org.junit.jupiter.api.extension.BeforeEachCallback;
|
25 | 27 | import org.junit.jupiter.api.extension.ExtensionContext;
|
@@ -58,7 +60,18 @@ public void beforeEach(final ExtensionContext context) throws Exception {
|
58 | 60 | @Override
|
59 | 61 | public void afterEach(final ExtensionContext context) throws Exception {
|
60 | 62 | try {
|
61 |
| - verifyNoOutput(); |
| 63 | + final Optional<Object> testInstance = context.getTestInstance(); |
| 64 | + |
| 65 | + if (testInstance.isPresent() |
| 66 | + && testInstance.get() instanceof WebDriverTestCase) { |
| 67 | + final WebDriverTestCase webDriverTestCase = (WebDriverTestCase) testInstance.get(); |
| 68 | + if (!webDriverTestCase.useRealBrowser()) { |
| 69 | + verifyNoOutput(); |
| 70 | + } |
| 71 | + } |
| 72 | + else { |
| 73 | + verifyNoOutput(); |
| 74 | + } |
62 | 75 | }
|
63 | 76 | finally {
|
64 | 77 | restoreSystemErr();
|
@@ -100,7 +113,6 @@ void restoreSystemErr() {
|
100 | 113 | /**
|
101 | 114 | * A {@link PrintStream} spying what is written on the wrapped stream.
|
102 | 115 | * It prints the content to the wrapped {@link PrintStream} and captures it simultaneously.
|
103 |
| - * @author Marc Guillemot |
104 | 116 | */
|
105 | 117 | class NSAPrintStreamWrapper extends PrintStream {
|
106 | 118 | private PrintStream wrapped_;
|
|
0 commit comments