You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by js...@apache.org on 2021/06/17 14:30:31 UTC
[sling-org-apache-sling-junit-core] branch
feature/SLING-10497-junit-jupiter-parameter-resolver-for-osgi updated: add
test logging
This is an automated email from the ASF dual-hosted git repository.
jsedding pushed a commit to branch feature/SLING-10497-junit-jupiter-parameter-resolver-for-osgi
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-junit-core.git
The following commit(s) were added to refs/heads/feature/SLING-10497-junit-jupiter-parameter-resolver-for-osgi by this push:
new 338285c add test logging
338285c is described below
commit 338285cdbce4ec6b76d8ee68a05ea89f4d665671
Author: Julian Sedding <js...@apache.org>
AuthorDate: Thu Jun 17 16:30:15 2021 +0200
add test logging
---
.../junit/jupiter/osgi/OSGiAnnotationTest.java | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/src/test/java/org/apache/sling/junit/jupiter/osgi/OSGiAnnotationTest.java b/src/test/java/org/apache/sling/junit/jupiter/osgi/OSGiAnnotationTest.java
index 269729e..f9ab984 100644
--- a/src/test/java/org/apache/sling/junit/jupiter/osgi/OSGiAnnotationTest.java
+++ b/src/test/java/org/apache/sling/junit/jupiter/osgi/OSGiAnnotationTest.java
@@ -26,7 +26,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.Extension;
+import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.TestWatcher;
import org.junit.jupiter.engine.JupiterTestEngine;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -41,11 +44,14 @@ import org.opentest4j.MultipleFailuresError;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.util.Collection;
import java.util.List;
+import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -79,8 +85,34 @@ import static org.junit.platform.commons.support.AnnotationSupport.findAnnotated
* test.
*/
@ExtendWith(OsgiContextExtension.class)
+@ExtendWith(OSGiAnnotationTest.LoggingReporter.class)
public class OSGiAnnotationTest {
+ public static class LoggingReporter implements TestWatcher {
+
+ @Override
+ public void testSuccessful(ExtensionContext context) {
+ LOG.info("Test success: {}", context.getDisplayName());
+ }
+
+ @Override
+ public void testFailed(ExtensionContext context, Throwable cause) {
+ LOG.info("Test failure: {}", context.getDisplayName(), cause);
+ }
+
+ private static String describeTest(ExtensionContext context) {
+ final String methodName = context.getRequiredTestMethod().getName();
+ final String displayName = context.getDisplayName();
+ if (displayName.startsWith(methodName)) {
+ return context.getRequiredTestClass().getSimpleName() + '#' + displayName;
+ } else {
+ return context.getRequiredTestClass().getSimpleName() + '#' + methodName + "() -> " + displayName;
+ }
+ }
+ }
+
+ private static final Logger LOG = LoggerFactory.getLogger(OSGiAnnotationTest.class);
+
private static final JupiterTestEngine JUPITER_TEST_ENGINE = new JupiterTestEngine();
OsgiContext osgiContext = new OsgiContext();