use of org.junit.platform.engine.support.descriptor.MethodSource in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method assertMethodSource.
private static void assertMethodSource(Method expectedMethod, TestDescriptor testDescriptor) {
assertThat(testDescriptor.getSource()).containsInstanceOf(MethodSource.class);
MethodSource methodSource = (MethodSource) testDescriptor.getSource().get();
assertThat(methodSource.getClassName()).isEqualTo(expectedMethod.getDeclaringClass().getName());
assertThat(methodSource.getMethodName()).isEqualTo(expectedMethod.getName());
assertThat(methodSource.getMethodParameterTypes()).isEqualTo(ClassUtils.nullSafeToString(expectedMethod.getParameterTypes()));
}
use of org.junit.platform.engine.support.descriptor.MethodSource in project intellij-community by JetBrains.
the class JUnit5TestExecutionListener method getLocationHintValue.
static String getLocationHintValue(TestSource testSource, boolean isTest) {
if (testSource instanceof CompositeTestSource) {
CompositeTestSource compositeTestSource = ((CompositeTestSource) testSource);
for (TestSource sourceFromComposite : compositeTestSource.getSources()) {
String locationHintValue = getLocationHintValue(sourceFromComposite, isTest);
if (!NO_LOCATION_HINT_VALUE.equals(locationHintValue)) {
return locationHintValue;
}
}
return NO_LOCATION_HINT_VALUE;
}
if (testSource instanceof FileSource) {
FileSource fileSource = (FileSource) testSource;
File file = fileSource.getFile();
String line = fileSource.getPosition().map(position -> ":" + position.getLine()).orElse("");
return "file://" + file.getAbsolutePath() + line;
}
if (testSource instanceof MethodSource) {
MethodSource methodSource = (MethodSource) testSource;
return javaLocation(methodSource.getClassName(), methodSource.getMethodName(), isTest);
}
if (testSource instanceof ClassSource) {
String className = ((ClassSource) testSource).getClassName();
return javaLocation(className, null, isTest);
}
return NO_LOCATION_HINT_VALUE;
}
use of org.junit.platform.engine.support.descriptor.MethodSource in project junit5 by junit-team.
the class DemoHierarchicalTestEngine method addTest.
public DemoHierarchicalTestDescriptor addTest(Method testMethod, Runnable executeBlock) {
UniqueId uniqueId = engineDescriptor.getUniqueId().append("test", testMethod.getName());
MethodSource source = MethodSource.from(testMethod);
DemoHierarchicalTestDescriptor child = new DemoHierarchicalTestDescriptor(uniqueId, testMethod.getName(), source, executeBlock);
engineDescriptor.addChild(child);
return child;
}
Aggregations