Skip to content

Commit

Permalink
WIP - revert test for an especially unlikely edge case, as the test i…
Browse files Browse the repository at this point in the history
…s hard to understand. In response to comment junit-pioneer#491 (comment)
  • Loading branch information
jbduncan committed Oct 15, 2021
1 parent d044d4a commit c106860
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 47 deletions.
Expand Up @@ -49,12 +49,12 @@ public ExecutionMode getExecutionMode() {

@Override
public Optional<Class<?>> getTestClass() {
return Optional.ofNullable(testClass);
return Optional.of(testClass);
}

@Override
public Optional<Method> getTestMethod() {
return Optional.ofNullable(testMethod);
return Optional.of(testMethod);
}

@Override
Expand Down
45 changes: 0 additions & 45 deletions src/test/java/org/junitpioneer/jupiter/ResourcesTests.java
Expand Up @@ -524,51 +524,6 @@ public void close() throws Exception {

// ---

@DisplayName("when ResourceManagerExtension is unable to find @New on a parameter")
@Nested
class WhenResourceManagerExtensionUnableToFindNewOnParameterTests {

@DisplayName("then an exception mentioning the parameter and the test method it's on is thrown")
@Test
void thenExceptionMentioningParameterAndTestMethodItsOnIsThrown() {
Class<?> exampleClass = String.class;
Method exampleMethod = ReflectionSupport.findMethod(exampleClass, "valueOf", Object.class).get();
Parameter exampleParameter = exampleMethod.getParameters()[0];

assertThatThrownBy(() -> new ResourceManagerExtension()
.resolveParameter( //
new TestParameterContext(exampleParameter),
new TestExtensionContext(exampleClass, exampleMethod)))
.isInstanceOf(ParameterResolutionException.class)
.hasMessage("Parameter `" + exampleParameter + "` on method `" + exampleMethod
+ "` is not annotated with @New");
}

@DisplayName("and the test method does not exist")
@Nested
class AndTestMethodDoesNotExistTests {

@DisplayName("then an exception mentioning just the parameter is thrown")
@Test
void thenExceptionMentioningJustParameterIsThrown() {
Class<?> exampleClass = String.class;
Method exampleMethod = ReflectionSupport.findMethod(exampleClass, "valueOf", Object.class).get();
Parameter exampleParameter = exampleMethod.getParameters()[0];

assertThatThrownBy(() -> new ResourceManagerExtension()
.resolveParameter(new TestParameterContext(exampleParameter),
new TestExtensionContext(null, null)))
.isInstanceOf(ParameterResolutionException.class)
.hasMessage("Parameter `" + exampleParameter
+ "` on unknown method is not annotated with @New");
}

}

}

// ---

@DisplayName("when a test class has a test method with a parameter annotated with both @New and @Shared")
@Nested
class WhenTestClassHasTestMethodWithParameterAnnotatedWithBothNewAndShared {
Expand Down

0 comments on commit c106860

Please sign in to comment.