Skip to content

Commit fc4e050

Browse files
dkropachevclaude
andcommitted
Fix @ScyllaSkip/@ScyllaOnly class-level annotations with @rule
When BaseCcmRule is used as @rule (instance-level), JUnit passes a Description for the test method, so description.getAnnotation() only finds method-level annotations. Class-level annotations like @ScyllaSkip on RequestIdGeneratorIT were not being detected. Now also check description.getTestClass().getAnnotation() as a fallback, which correctly finds class-level annotations regardless of whether the rule is used as @rule or @ClassRule. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 08bf881 commit fc4e050

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm

test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/BaseCcmRule.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ protected void after() {
7272
@Override
7373
public Statement apply(Statement base, Description description) {
7474
// Scylla-specific annotations
75+
// Check both method-level and class-level annotations.
76+
// When used as @Rule (not @ClassRule), description.getAnnotation() only finds
77+
// method-level annotations, so we also check the test class directly.
7578
ScyllaSkip scyllaSkip = description.getAnnotation(ScyllaSkip.class);
79+
if (scyllaSkip == null && description.getTestClass() != null) {
80+
scyllaSkip = description.getTestClass().getAnnotation(ScyllaSkip.class);
81+
}
7682
if (scyllaSkip != null) {
7783
if (CcmBridge.isDistributionOf(BackendType.SCYLLA)) {
7884
return new Statement() {
@@ -88,6 +94,9 @@ public void evaluate() {
8894
}
8995

9096
ScyllaOnly scyllaOnly = description.getAnnotation(ScyllaOnly.class);
97+
if (scyllaOnly == null && description.getTestClass() != null) {
98+
scyllaOnly = description.getTestClass().getAnnotation(ScyllaOnly.class);
99+
}
91100
if (scyllaOnly != null) {
92101
if (!CcmBridge.isDistributionOf(BackendType.SCYLLA)) {
93102
return new Statement() {

0 commit comments

Comments
 (0)