Skip to content

Commit

Permalink
#690: Cover some corner-case bugs which happen when generating object…
Browse files Browse the repository at this point in the history
… keys for ParameterizedTests.
  • Loading branch information
steve-todorov committed May 12, 2023
1 parent ccbf797 commit 096ff24
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/test/java/org/carlspring/cloud/storage/s3fs/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import ch.qos.logback.classic.pattern.TargetLengthBasedClassNameAbbreviator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;

import static java.util.UUID.randomUUID;

/**
Expand Down Expand Up @@ -63,9 +65,17 @@ protected String getTestBasePath()

if (!isAbstract)
{
Method method = clazz.getDeclaredMethod(methodName);
Test hasTestAnnotation = method.getDeclaredAnnotation(Test.class);
if (hasTestAnnotation != null)
Method method = Arrays.stream(clazz.getDeclaredMethods())
.filter(m -> m.getName().equals(methodName))
.findFirst()
.orElse(null);
if(method == null) {
throw new NoSuchMethodException(className+"#"+methodName);
}
boolean hasTestAnnotation = Arrays.stream(method.getDeclaredAnnotations())
.anyMatch(a -> a.annotationType() == Test.class ||
a.annotationType() == ParameterizedTest.class);
if (hasTestAnnotation)
{
// Additional prefix after the class name for better differentiation.
String prNumber = System.getenv(PR_NUMBER_ENV_VAR);
Expand Down

0 comments on commit 096ff24

Please sign in to comment.