@Override public FileLocator getFileLocator() { FileLocator locator = super.getFileLocator(); if (locator == null){ return projectFileLocator; } return locator; }
private void suiteFinished(int total, int failures, int errors ,long time) { int addFail = failures; int addError = errors; int addPass = total - failures - errors; for(Testcase tc: testSession.getCurrentSuite().getTestcases()){ switch(tc.getStatus()){ case ERROR: addError--;break; case FAILED: addFail--;break; default: addPass--; } } for(int i=0; i<addPass; i++){ JUnitTestcase tc = new JUnitTestcase("Unknown", "Unknown", testSession); //NOI18N tc.setStatus(Status.PASSED); testSession.addTestCase(tc); } for(int i=0; i<addFail; i++){ JUnitTestcase tc = new JUnitTestcase("Unknown", "Unknown", testSession); //NOI18N tc.setStatus(Status.FAILED); testSession.addTestCase(tc); } for(int i=0; i<addError; i++){ JUnitTestcase tc = new JUnitTestcase("Unknown", "Unknown", testSession); //NOI18N tc.setStatus(Status.ERROR); testSession.addTestCase(tc); } lastSuiteTime = time; state = State.SUITE_FINISHED; }
private void testCaseFinished(){ if (report == null){ report = testSession.getReport(0); }else{ report.update(testSession.getReport(0)); } CoreManager junitManager = getManagerProvider(); if(junitManager != null) { junitManager.displayReport(testSession, report, false); } else { // update report status as a minimum report.setCompleted(false); } state = State.SUITE_STARTED; }
assert "testsuite".equals(testSuite.getName()) : "Root name " + testSuite.getName(); //NOI18N TestSuite suite = new TestSuite(testSuite.getAttributeValue("name")); session.addSuite(suite); Manager.getInstance().displaySuiteRunning(session, suite.getName()); test.setLocation(test.getClassName().replace('.', '/') + ".java"); session.addTestCase(test); Manager.getInstance().displayReport(session, session.getReport(timeinmilis)); File output = new File(outputDir, runningTestClass + suffix + "-output.txt"); if (output.isFile()) {
public UnitTestRunner(PhpProject project, TestRunInfo info, ControllableRerunHandler rerunHandler, List<PhpTestingProvider> testingProviders) { assert project != null; assert rerunHandler != null; assert info != null; assert testingProviders != null; this.project = project; this.info = info; this.rerunHandler = rerunHandler; coverageProvider = project.getLookup().lookup(PhpCoverageProvider.class); assert coverageProvider != null; this.testingProviders = testingProviders; testSession = new TestSession(getOutputTitle(project, info), project, map(info.getSessionType()), new PhpTestRunnerNodeFactory(new CallStackCallback(project))); testSession.setRerunHandler(rerunHandler); }
private void closePereviousReport(){ TestSuite currentSuite = testSession.getCurrentSuite(); if (currentSuite != null){ report = testSession.getReport(lastSuiteTime); }else{ report.update(testSession.getReport(lastSuiteTime));
private void testCaseStarted(String name){ JUnitTestcase tc = new JUnitTestcase(name, "JUnit Test", testSession); testSession.addTestCase(tc); //NOI18N state = State.TESTCASE_STARTED; }
/** * Notifies that a test suite was just started. * * @param suiteName name of the suite; or {@code null} * if the suite name is unknown */ private void suiteStarted(final String suiteName) { closePereviousReport(); TestSuite suite = new JUnitTestSuite(suiteName, testSession); testSession.addSuite(suite); CoreManager junitManager = getManagerProvider(); if(junitManager != null) { junitManager.displaySuiteRunning(testSession, suite); } state = State.SUITE_STARTED; platformSources = null; }
public boolean enabled(RerunType type) { if ((scriptFile == null) || (targets == null) || (targets.length == 0)){ return false; } if (scriptFile.getName().equals(JUNIT_CUSTOM_FILENAME + ".xml")){ //NOI18N return true; } Project project = testSession.getProject(); if(project == null) { // could not locate the project for which the testSession was invoked for return false; } ActionProvider actionProvider = project.getLookup().lookup(ActionProvider.class); if (actionProvider != null){ boolean runSupported = false; for (String action : actionProvider.getSupportedActions()) { if (action.equals(targets[0])) { runSupported = true; break; } } if (runSupported && actionProvider.isActionEnabled(targets[0], lookup)) { return true; } } return false; }
testSession.setRerunHandler(new JUnitExecutionManager(session, testSession, props)); File projectFile = FileUtil.toFile(project.getProjectDirectory()); if(projectFile != null) {
session = new TestSession(createSessionName(mvnprj.getMavenProject().getId()), prj, TestSession.SessionType.TEST, new JUnitTestRunnerNodeFactory(session, prj)); session.setRerunHandler(new RerunHandler() { public @Override void rerun() {
@Override public TestCase addTestCase(String name, String type) { checkFrozen(); checkFinished(); Parameters.notWhitespace("name", name); // NOI18N Parameters.notWhitespace("type", type); // NOI18N TestSession session = testSession.getTestSession(); Testcase testCase = new Testcase(name, type, session); if (location != null) { testCase.setLocation(FileUtil.toFile(location).getAbsolutePath()); } session.addTestCase(testCase); return new TestCaseImpl(this, testCase); }
@NbBundle.Messages({ "# {0} - provider name", "# {1} - suite name", "TestSessionImpl.suite.name=[{0}] {1}", }) @Override public TestSuite addTestSuite(String name, FileObject location) { Parameters.notWhitespace("name", name); // NOI18N checkFrozen(); String suiteName = Bundle.TestSessionImpl_suite_name(testingProvider.getDisplayName(), name); org.netbeans.modules.gsf.testrunner.api.TestSuite testSuite = new org.netbeans.modules.gsf.testrunner.api.TestSuite(suiteName); manager.displaySuiteRunning(testSession, suiteName); testSession.addSuite(testSuite); return new TestSuiteImpl(this, testSuite, location); }
Project project = testSession.getProject(); if(ProjectManager.getDefault().isValid(project)) { ActionProvider actionProvider = project.getLookup().lookup(ActionProvider.class);
FileObject testFO = testSession.getFileLocator().find(javacIncludes); lookup = Lookups.fixed(testFO); FileObject testFO = testSession.getFileLocator().find(testIncludes); lookup = Lookups.fixed(testFO); String testMethods = properties.getProperty("test.methods");//NOI18N if(testClass != null) { FileObject testFO = testSession.getFileLocator().find(testClass.replace('.', '/') + ".java"); //NOI18N if (testMethods != null) { SingleMethod methodSpec = new SingleMethod(testFO, testMethods); String methodName = properties.getProperty("methodname"); //NOI18N if (className != null){ FileObject testFO = testSession.getFileLocator().find(className.replace('.', '/') + ".java"); //NOI18N if (methodName != null){ SingleMethod methodSpec = new SingleMethod(testFO, methodName);
/** */ private boolean tryParseBriefHeader(String testcaseHeader) { final Matcher matcher = regexp.getTestcaseHeaderBriefPattern() .matcher(testcaseHeader); if (matcher.matches()) { String methodName = matcher.group(1); String clsName = matcher.group(2); boolean error = (matcher.group(3) == null); testcase = findTest(testSession.getCurrentSuite(), methodName); if (testcase == null){ // probably TestListener interface not reported test progress for some reason (for ex. debug mode) testcase = new JUnitTestcase(methodName, "JUnit test", testSession); testSession.addTestCase(testcase); } testcase.setClassName(clsName); Trouble trouble = testcase.getTrouble(); if (trouble == null){ trouble = new Trouble(error); testcase.setTrouble(trouble); }else{ trouble.setError(error); trouble.setStackTrace(null); } return true; } else { return false; } }
@Override public void finish(long time) { checkFrozen(); checkFinished(); finished = true; TestSession session = testSession.getTestSession(); testSession.getManager().displayReport(session, session.getReport(time)); }
props.put("work.dir", testSession.getProject().getProjectDirectory().getPath()); //NOI18N ClassPath cp = ClassPath.getClassPath(someTestFO, ClassPath.EXECUTE); props.put("classpath", cp != null ? cp.toString(ClassPath.PathConversionMode.FAIL) : "");//NOI18N Project p = testSession.getProject(); String platformId = null; try {
static void openCallstackFrame(Node node, @NonNull String frameInfo) { JUnitTestMethodNode methodNode = getTestMethodNode(node); FileLocator locator = methodNode.getTestcase().getSession().getFileLocator(); if (locator == null) { return;
@Override public void run() { final ResultWindow window = ResultWindow.getInstance(); Mode mode = WindowManager.getDefault().findMode(window); boolean isInSlidingMode = mode != null && mode.getName().contains("SlidingSide"); //NOI18N if (window.isOpened() && !isInSlidingMode) { window.promote(); } else if (!window.isOpened() || (window.isOpened() && !window.isShowing() && isInSlidingMode)) { Icon icon = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/gsf/testrunner/ui/resources/testResults.png")); //NOI18N String projectname = ProjectUtils.getInformation(session.getProject()).getDisplayName(); int total = displayHandler.getTotalTests(); String title = total == 0 ? Bundle.LBL_NotificationDisplayer_NoTestsExecuted_title(projectname) : Bundle.LBL_NotificationDisplayer_title(total, projectname); if(bubbleTask.cancel()) { bubbleTask.schedule(0); } bubbleNotification = NotificationDisplayer.getDefault().notify(title, icon, Bundle.LBL_NotificationDisplayer_detailsText(), new ActionListener() { @Override public void actionPerformed(ActionEvent e) { window.promote(); bubbleTask.cancel(); } }); bubbleTask.schedule(15000); } } });