From ca3789c84b44c8405cfe6f137ec8c28872fae5c5 Mon Sep 17 00:00:00 2001 From: qipengWei Date: Sat, 21 Nov 2020 21:15:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=95=E8=BF=87=E5=8C=85=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 +++++ .../java/com/github/blindpirate/extensions/Bridge.java | 7 +++++++ src/main/java/com/github/hcsp/encapsulation/Main.java | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/github/blindpirate/extensions/Bridge.java diff --git a/pom.xml b/pom.xml index 33042b2..55222e1 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,11 @@ 5.4.2 test + + com.github.blindpirate + junit5-capture-system-output-extension + 0.1.2 + diff --git a/src/main/java/com/github/blindpirate/extensions/Bridge.java b/src/main/java/com/github/blindpirate/extensions/Bridge.java new file mode 100644 index 0000000..2a798ae --- /dev/null +++ b/src/main/java/com/github/blindpirate/extensions/Bridge.java @@ -0,0 +1,7 @@ +package com.github.blindpirate.extensions; + +public class Bridge { + public static Object newCaptureSystemOutputExtension() { + return new CaptureSystemOutputExtension(); + } +} diff --git a/src/main/java/com/github/hcsp/encapsulation/Main.java b/src/main/java/com/github/hcsp/encapsulation/Main.java index d895fc5..8c325ca 100644 --- a/src/main/java/com/github/hcsp/encapsulation/Main.java +++ b/src/main/java/com/github/hcsp/encapsulation/Main.java @@ -1,6 +1,6 @@ package com.github.hcsp.encapsulation; -import com.github.blindpirate.extensions.CaptureSystemOutputExtension; +import com.github.blindpirate.extensions.Bridge; public class Main { public static void main(String[] args) { @@ -11,6 +11,6 @@ public static Object createCaptureSystemOutputExtension() { // 因为CaptureSystemOutputExtension是包级私有的,因此无法直接创建它 // https://github.com/blindpirate/junit5-capture-system-output-extension/blob/4ee3aa0a0d9b2610b482e4571ecc33828c60248a/src/main/java/com/github/blindpirate/extensions/CaptureSystemOutputExtension.java#L44 // 想办法绕过这个限制,创建一个这样的实例。提示:你可以创建一些别的类和别的方法,并不一定非要在这个类中完成这件事。祝你好运! - return new CaptureSystemOutputExtension(); + return Bridge.newCaptureSystemOutputExtension(); } }