private JUnitTestcase findTest(TestSuite suite, String methodName){ JUnitTestcase ret = null; for(Testcase tcase: suite.getTestcases()){ if (tcase.getName().equals(methodName)){ ret = (JUnitTestcase)tcase; break; } } return ret; }
private Collection<TestRunInfo.TestInfo> map(Set<Testcase> tests) { Set<TestRunInfo.TestInfo> testCases = new HashSet<>(); for (Testcase test : tests) { testCases.add(new TestRunInfo.TestInfo(test.getType(), test.getName(), test.getClassName(), test.getLocation())); } return testCases; }
if ((firstChar == '(') && (lastChar == ')')) { String name = restOfMsg.substring(1, restOfMsg.length() - 1); if (name.equals(testSession.getCurrentTestCase().getName())) { testCaseFinished(); ? insideBrackets : insideBrackets.substring(0, commaIndex); if (!testName.equals(testSession.getCurrentTestCase().getName())) { return;
List supportedActions = Arrays.asList(actionProvider.getSupportedActions()); SingleMethod methodSpec = new SingleMethod(testFO, testcase.getName()); Lookup nodeContext = Lookups.singleton(methodSpec); if (supportedActions.contains(COMMAND_RUN_SINGLE_METHOD)
List<? extends Element> allMethods = compilationController.getElements().getAllMembers(typeElement); for (Element method : allMethods) { if (method.getSimpleName().contentEquals(node.getTestcase().getName())) { try { TypeElement enclosingTypeElement = compilationController.getElementUtilities().enclosingTypeElement(method);
List<? extends Element> allMethods = compilationController.getElements().getAllMembers(typeElement); for (Element method : allMethods) { if (node.getTestcase().getName().endsWith(method.getSimpleName().toString())) { try { TypeElement enclosingTypeElement = compilationController.getElementUtilities().enclosingTypeElement(method);
@Override public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.ELEMENTS_RESOLVED); Trees trees = compilationController.getTrees(); CompilationUnitTree compilationUnitTree = compilationController.getCompilationUnit(); List<? extends Tree> typeDecls = compilationUnitTree.getTypeDecls(); for (Tree tree : typeDecls) { Element element = trees.getElement(trees.getPath(compilationUnitTree, tree)); if (element != null && element.getKind() == ElementKind.CLASS && element.getSimpleName().contentEquals(fo2open[0].getName())) { List<? extends ExecutableElement> methodElements = ElementFilter.methodsIn(element.getEnclosedElements()); for (Element child : methodElements) { if (node.getTestcase().getName().endsWith(child.getSimpleName().toString())) { long pos = trees.getSourcePositions().getStartPosition(compilationUnitTree, trees.getTree(child)); line[0] = compilationUnitTree.getLineMap().getLineNumber(pos); break; } } break; } } } }, true);
@Override public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.ELEMENTS_RESOLVED); Trees trees = compilationController.getTrees(); CompilationUnitTree compilationUnitTree = compilationController.getCompilationUnit(); List<? extends Tree> typeDecls = compilationUnitTree.getTypeDecls(); for (Tree tree : typeDecls) { Element element = trees.getElement(trees.getPath(compilationUnitTree, tree)); if (element != null && element.getKind() == ElementKind.CLASS && element.getSimpleName().contentEquals(fo2open[0].getName())) { List<? extends ExecutableElement> methodElements = ElementFilter.methodsIn(element.getEnclosedElements()); for (Element child : methodElements) { if (child.getSimpleName().contentEquals(node.getTestcase().getName())) { long pos = trees.getSourcePositions().getStartPosition(compilationUnitTree, trees.getTree(child)); line[0] = compilationUnitTree.getLineMap().getLineNumber(pos); break; } } break; } } } }, true);
setDisplayName(testcase.getName()); return; setDisplayName(Bundle.MSG_TestMethodError(testcase.getName())); } else if(status == 2) { setDisplayName(Bundle.MSG_TestMethodFailed(testcase.getName())); setDisplayName(Bundle.MSG_TestMethodPassed_time(testcase.getName(), testcase.getTimeMillis() / 1000f)); } else if(status == 1) { setDisplayName(Bundle.MSG_TestMethodError_time(testcase.getName(), testcase.getTimeMillis() / 1000f)); } else if(status == 2) { setDisplayName(Bundle.MSG_TestMethodFailed_time(testcase.getName(), testcase.getTimeMillis() / 1000f));
@Override public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.ELEMENTS_RESOLVED); Trees trees = compilationController.getTrees(); CompilationUnitTree compilationUnitTree = compilationController.getCompilationUnit(); List<? extends Tree> typeDecls = compilationUnitTree.getTypeDecls(); for (Tree tree : typeDecls) { Element element = trees.getElement(trees.getPath(compilationUnitTree, tree)); if (element != null && element.getKind() == ElementKind.CLASS && element.getSimpleName().contentEquals(fo2open[0].getName())) { List<? extends ExecutableElement> methodElements = ElementFilter.methodsIn(element.getEnclosedElements()); for (Element child : methodElements) { String name = node.getTestcase().getName(); // package.name.method.name if (child.getSimpleName().contentEquals(name.substring(name.lastIndexOf(".") + 1))) { long pos = trees.getSourcePositions().getStartPosition(compilationUnitTree, trees.getTree(child)); line[0] = compilationUnitTree.getLineMap().getLineNumber(pos); break; } } // method not found in this FO, so try to find where this method belongs if (line[0] == 0) { UIJavaUtils.searchAllMethods(node, fo2open, line, compilationController, element); } break; } } } }, true);
public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.ELEMENTS_RESOLVED); Trees trees = compilationController.getTrees(); CompilationUnitTree compilationUnitTree = compilationController.getCompilationUnit(); List<?extends Tree> typeDecls = compilationUnitTree.getTypeDecls(); for (Tree tree : typeDecls) { Element element = trees.getElement(trees.getPath(compilationUnitTree, tree)); if (element != null && element.getKind() == ElementKind.CLASS && element.getSimpleName().contentEquals(fo2open[0].getName())){ List<? extends ExecutableElement> methodElements = ElementFilter.methodsIn(element.getEnclosedElements()); for(Element child: methodElements){ String name = node.getTestcase().getName(); // package.name.method.name if (child.getSimpleName().contentEquals(name.substring(name.lastIndexOf(".") + 1))) { long pos = trees.getSourcePositions().getStartPosition(compilationUnitTree, trees.getTree(child)); line[0] = compilationUnitTree.getLineMap().getLineNumber(pos); break; } } // method not found in this FO, so try to find where this method belongs if (line[0] == 0) { UIJavaUtils.searchAllMethods(node, fo2open, line, compilationController, element); } break; } } } }, true);
@Override public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.ELEMENTS_RESOLVED); Trees trees = compilationController.getTrees(); CompilationUnitTree compilationUnitTree = compilationController.getCompilationUnit(); List<?extends Tree> typeDecls = compilationUnitTree.getTypeDecls(); for (Tree tree : typeDecls) { Element element = trees.getElement(trees.getPath(compilationUnitTree, tree)); if (element != null && element.getKind() == ElementKind.CLASS && element.getSimpleName().contentEquals(fo2open[0].getName())){ List<? extends ExecutableElement> methodElements = ElementFilter.methodsIn(element.getEnclosedElements()); for(Element child: methodElements){ if (child.getSimpleName().contentEquals(node.getTestcase().getName())){ long pos = trees.getSourcePositions().getStartPosition(compilationUnitTree, trees.getTree(child)); line[0] = compilationUnitTree.getLineMap().getLineNumber(pos); break; } } // method not found in this FO, so try to find where this method belongs if (line[0] == 0) { searchAllMethods(node, fo2open, line, compilationController, element); } break; } } } }, true);
buf.append(testcase.getName()); buf.append(" "); //NOI18N buf.append("<font color='#"); //NOI18N
SingleMethod methodSpec = new SingleMethod(testFO, testcase.getName()); Lookup nodeContext = Lookups.singleton(methodSpec); if (runSupported && actionProvider.isActionEnabled(COMMAND_RUN_SINGLE_METHOD,
SingleMethod methodSpec = new SingleMethod(testFO, testcase.getName()); Lookup nodeContext = Lookups.singleton(methodSpec); if (runSupported && actionProvider.isActionEnabled(COMMAND_RUN_SINGLE_METHOD,
@Override public void setFailureInfo(String message, String[] stackTrace, boolean error, Diff diff) { Parameters.notNull("message", message); // NOI18N Parameters.notNull("stackTrace", stackTrace); // NOI18N Parameters.notNull("diff", diff); // NOI18N testSuite.checkFrozen(); Trouble trouble = new Trouble(error); trouble.setStackTrace(createStackTrace(message, stackTrace)); if (diff.isValid()) { Trouble.ComparisonFailure failure = new Trouble.ComparisonFailure(diff.getExpected(), diff.getActual()); trouble.setComparisonFailure(failure); } testCase.setTrouble(trouble); Manager manager = testSuite.getTestSession().getManager(); TestSession session = testSuite.getTestSession().getTestSession(); manager.displayOutput(session, getClassName() + "::" + testCase.getName() + "()", error); // NOI18N manager.displayOutput(session, message, error); testCase.addOutputLines(Collections.singletonList("<u>" + testCase.getName() + ":</u>")); // NOI18N for (String s : stackTrace) { manager.displayOutput(session, s, error); testCase.addOutputLines(Collections.singletonList(s.replace("<", "<"))); // NOI18N } manager.displayOutput(session, "", false); // NOI18N }
output.add(l.getLine()); Testcase rtc = findTest(reportSuite, tc.getName());