private static String getTestCaseName(TestIdentifier description) { try { TestSource testSource = description.getSource().get(); if (testSource instanceof MethodSource) { return ((MethodSource) testSource).getClassName(); } return description.getDisplayName().split("\\(|\\)")[1]; } catch (Exception e) { return description.getDisplayName(); } }
/** * Creates a new {@link AbstractBenchmarkDescriptor} given {@link UniqueId}, {@code displayName} and a {@link TestSource}. * * @param uniqueId the {@link UniqueId} for this descriptor. * @param displayName * @param source source this descriptor. */ public AbstractBenchmarkDescriptor(UniqueId uniqueId, String displayName, TestSource source) { super(uniqueId, displayName, source); Set<TestTag> tags = Collections.emptySet(); if (source instanceof ClassSource) { tags = DescriptorUtils.getTags(((ClassSource) source).getJavaClass()); } if (source instanceof MethodSource) { try { tags = DescriptorUtils.getTags(Class.forName(((MethodSource) source).getClassName())); } catch (ClassNotFoundException e) { throw new IllegalStateException(e); } } this.tags = tags; }
String realClassName = methodSource.getClassName();
private boolean shouldRun( MethodSource source ) { String testClass = TestListResolver.toClassFileName( source.getClassName() ); String testMethod = source.getMethodName(); return this.testListResolver.shouldRun( testClass, testMethod ); } }