use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class OtherClass method methodResolutionByUniqueIdWithMissingMethodName.
@Test
void methodResolutionByUniqueIdWithMissingMethodName() {
UniqueId uniqueId = uniqueIdForMethod(getClass(), "()");
resolve(request().selectors(selectUniqueId(uniqueId)));
assertTrue(engineDescriptor.getDescendants().isEmpty());
var result = verifySelectorProcessed(selectUniqueId(uniqueId));
assertThat(result.getStatus()).isEqualTo(FAILED);
//
assertThat(result.getThrowable().get()).isInstanceOf(//
PreconditionViolationException.class).hasMessageStartingWith("Method [()] does not match pattern");
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class OtherClass method methodOfInnerClassByUniqueId.
@Test
void methodOfInnerClassByUniqueId() {
UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test5()").toString());
resolve(request().selectors(selector));
assertEquals(2, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(OtherTestClass.NestedTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test5()"));
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class OtherClass method resolvingUniqueIdWithWrongParamsResolvesNothing.
@Test
void resolvingUniqueIdWithWrongParamsResolvesNothing() {
UniqueId uniqueId = uniqueIdForMethod(HerTestClass.class, "test7(java.math.BigDecimal)");
resolve(request().selectors(selectUniqueId(uniqueId)));
assertTrue(engineDescriptor.getDescendants().isEmpty());
assertUnresolved(selectUniqueId(uniqueId));
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class OtherClass method methodResolutionByUniqueIdWithBogusParameters.
@Test
void methodResolutionByUniqueIdWithBogusParameters() {
UniqueId uniqueId = uniqueIdForMethod(getClass(), "methodName(java.lang.String, junit.foo.Enigma)");
resolve(request().selectors(selectUniqueId(uniqueId)));
assertTrue(engineDescriptor.getDescendants().isEmpty());
var result = verifySelectorProcessed(selectUniqueId(uniqueId));
assertThat(result.getStatus()).isEqualTo(FAILED);
//
assertThat(result.getThrowable().get()).isInstanceOf(//
JUnitException.class).hasMessage("Failed to load parameter type [%s] for method [%s] in class [%s].", "junit.foo.Enigma", "methodName", getClass().getName());
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class OtherClass method resolvingDynamicTestByUniqueIdResolvesUpToParentTestFactory.
@Test
void resolvingDynamicTestByUniqueIdResolvesUpToParentTestFactory() {
Class<?> clazz = MyTestClass.class;
UniqueId factoryUid = uniqueIdForTestFactoryMethod(clazz, "dynamicTest()");
UniqueId dynamicTestUid = factoryUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#1");
UniqueId differentDynamicTestUid = factoryUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#2");
resolve(request().selectors(selectUniqueId(dynamicTestUid)));
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), factoryUid);
TestDescriptor testClassDescriptor = getOnlyElement(engineDescriptor.getChildren());
TestDescriptor testFactoryDescriptor = getOnlyElement(testClassDescriptor.getChildren());
DynamicDescendantFilter dynamicDescendantFilter = getDynamicDescendantFilter(testFactoryDescriptor);
assertThat(dynamicDescendantFilter.test(dynamicTestUid, 42)).isTrue();
assertThat(dynamicDescendantFilter.test(differentDynamicTestUid, 42)).isFalse();
assertAllSelectorsResolved();
}
Aggregations