diff --git a/org.osgi.test.junit5/src/main/java/org/osgi/test/junit5/context/BundleContextExtension.java b/org.osgi.test.junit5/src/main/java/org/osgi/test/junit5/context/BundleContextExtension.java index 7305a960..cda039b7 100644 --- a/org.osgi.test.junit5/src/main/java/org/osgi/test/junit5/context/BundleContextExtension.java +++ b/org.osgi.test.junit5/src/main/java/org/osgi/test/junit5/context/BundleContextExtension.java @@ -130,6 +130,11 @@ static Store getStore(ExtensionContext extensionContext) { @Override protected Object resolveValue(TargetType targetType, InjectBundleContext injection, ExtensionContext extensionContext) throws ParameterResolutionException { - return getBundleContext(extensionContext); + BundleContext retval = getBundleContext(extensionContext); + if (retval == null) { + throw new ParameterResolutionException( + "Bundle context was null. Check that you are running your test in an OSGi framework."); + } + return retval; } }