private String getDisplayNameBottomUp(MethodInvocation invocation) { if (invocation.parent() == null || !(invocation.parent() instanceof MethodInvocation)) return invocation.target().toString(); else return getTestNameBottomUp((MethodInvocation) invocation.parent()) + " " + invocation.target().toString(); }
private String getTestNameBottomUp(MethodInvocation invocation) { String result = ""; while (invocation != null) { MethodInvocation nameInvocation = invocation; if (invocation.target().name().equals("taggedAs") && invocation.target() instanceof MethodInvocation) { nameInvocation = (MethodInvocation) invocation.target(); } if (!nameInvocation.target().canBePartOfTestName() || (!invocation.name().equals("in") && invocation.canBePartOfTestName())) return null; String targetText = (nameInvocation.name().equals("in") || nameInvocation.name().equals("taggedAs")) ? nameInvocation.target().toString() : (nameInvocation.target().toString() + " " + nameInvocation.name()); result = targetText + " " + result; if (invocation.parent() != null && invocation.parent() instanceof MethodInvocation) invocation = (MethodInvocation) invocation.parent(); else invocation = null; } return result.trim(); }