Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions documentation/modules/ROOT/pages/release-notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Please refer to the xref:overview.adoc[User Guide] for comprehensive
reference documentation for programmers writing tests, extension authors, and engine
authors as well as build tool and IDE vendors.

include::partial$release-notes/release-notes-5.14.2.adoc[]

include::partial$release-notes/release-notes-5.14.1.adoc[]

include::partial$release-notes/release-notes-5.14.0.adoc[]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[[v5.14.2]]
== 5.14.2

*Date of Release:* ❓

*Scope:* Bug fixes and enhancements since 5.14.1

For a complete list of all _closed_ issues and pull requests for this release, consult the
link:{junit-framework-repo}+/milestone/❓?closed=1+[5.14.2] milestone page in the JUnit
repository on GitHub.


[[v5.14.2-junit-platform]]
=== JUnit Platform

No changes.


[[v5.14.2-junit-jupiter]]
=== JUnit Jupiter

[[v5.14.2-junit-jupiter-bug-fixes]]
==== Bug Fixes

* Allow using `@ResourceLock` on classes annotated with `@ClassTemplate` (or
`@ParameterizedClass`).


[[v5.14.2-junit-vintage]]
=== JUnit Vintage

No changes.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package org.junit.jupiter.engine.descriptor;

import static java.util.Collections.emptySet;
import static org.apiguardian.api.API.Status.INTERNAL;
import static org.junit.jupiter.engine.descriptor.CallbackSupport.invokeAfterCallbacks;
import static org.junit.jupiter.engine.descriptor.CallbackSupport.invokeBeforeCallbacks;
Expand All @@ -34,6 +35,7 @@
import org.junit.jupiter.engine.extension.MutableExtensionRegistry;
import org.junit.platform.engine.TestSource;
import org.junit.platform.engine.UniqueId;
import org.junit.platform.engine.support.hierarchical.ExclusiveResource;
import org.junit.platform.engine.support.hierarchical.ThrowableCollector;

/**
Expand Down Expand Up @@ -108,6 +110,12 @@ public Function<ResourceLocksProvider, Set<ResourceLocksProvider.Lock>> getResou

// --- Node ----------------------------------------------------------------

@Override
public Set<ExclusiveResource> getExclusiveResources() {
// Resources are already collected and returned by the enclosing ClassTemplateTestDescriptor
return emptySet();
}

@Override
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context) {
MutableExtensionRegistry registry = context.getExtensionRegistry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import org.junit.jupiter.api.extension.ParameterResolutionException;
import org.junit.jupiter.api.extension.ParameterResolver;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.parallel.ResourceLock;
import org.junit.jupiter.engine.descriptor.ClassTemplateInvocationTestDescriptor;
import org.junit.jupiter.engine.descriptor.ClassTemplateTestDescriptor;
import org.junit.jupiter.engine.descriptor.ClassTestDescriptor;
Expand All @@ -94,6 +95,7 @@
import org.junit.platform.engine.UniqueId;
import org.junit.platform.engine.discovery.DiscoverySelectors;
import org.junit.platform.engine.reporting.ReportEntry;
import org.junit.platform.engine.support.hierarchical.ExclusiveResource;
import org.junit.platform.testkit.engine.EngineExecutionResults;
import org.opentest4j.AssertionFailedError;
import org.opentest4j.TestAbortedException;
Expand Down Expand Up @@ -1003,6 +1005,24 @@ void ignoresComposedAnnotations() {
assertThat(engineDescriptor.getDescendants()).isEmpty();
}

@Test
void classTemplateWithResourceLockCollectsExclusiveResources() {
var results = discoverTestsForClass(ClassTemplateWithResourceLockTestCase.class);
var classTemplateDescriptor = (ClassTemplateTestDescriptor) getOnlyElement(
results.getEngineDescriptor().getChildren());

assertThat(classTemplateDescriptor.getExclusiveResources()).extracting(
ExclusiveResource::getKey).containsExactly("test-resource");
}

@Test
void classTemplateWithResourceLockExecutesSuccessfully() {
var results = executeTestsForClass(ClassTemplateWithResourceLockTestCase.class);

results.testEvents().assertStatistics(stats -> stats.started(2).succeeded(2));
results.containerEvents().assertStatistics(stats -> stats.started(4).succeeded(4));
}

// -------------------------------------------------------------------

private static Stream<String> allReportEntryValues(EngineExecutionResults results) {
Expand Down Expand Up @@ -1566,4 +1586,15 @@ void test() {
}
}

@SuppressWarnings("JUnitMalformedDeclaration")
@ClassTemplate
@ExtendWith(TwoInvocationsClassTemplateInvocationContextProvider.class)
@ResourceLock("test-resource")
static class ClassTemplateWithResourceLockTestCase {
@Test
void test() {
// This test verifies that @ResourceLock works with @ClassTemplate (issue #5155)
}
}

}