/** * Initialize a <code>ILaunchConfigurationWorkingCopy</code> either by using an existing one (if * found), or using a default configuration (for example, the one used for the most recent * launch), or by creating a new one based on the <code>project</code> name and the <code>confName * </code>. * * @throws CoreException if getting an working copy from an existing configuration fails */ private static ILaunchConfigurationWorkingCopy createLaunchConfiguration( IProject project, String confName, RunInfo runInfo) { ILaunchManager launchManager = getLaunchManager(); ILaunchConfiguration config = ConfigurationHelper.findConfiguration(launchManager, project, confName, runInfo); ILaunchConfigurationWorkingCopy configWC = null; if (null != config) { try { configWC = config.getWorkingCopy(); } catch (CoreException cex) { TestNGPlugin.log( new Status( IStatus.ERROR, TestNGPlugin.PLUGIN_ID, TestNGPluginConstants.LAUNCH_ERROR, "Cannot create working copy of existing launcher " + config.getName(), cex)); } } if (null == configWC) { if (confName == null && runInfo != null) { confName = runInfo.getClassName() + "." + runInfo.getMethodName(); } configWC = ConfigurationHelper.createBasicConfiguration(launchManager, project, confName); } return configWC; }
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (m_searchString == null || m_searchString.length() == 0) { return true; } RunInfo p = (RunInfo) element; return p.getTestName().toLowerCase().matches(m_searchString.toLowerCase()); }
private static void launchMethodBasedConfiguration( IJavaProject ijp, IMethod[] methods, String annotationType, String runMode, RunInfo runInfo) { Set typesSet = new HashSet(); for (int i = 0; i < methods.length; i++) { typesSet.add(methods[i].getDeclaringType()); } List /*<String>*/ methodNames = new ArrayList(); Map /*<String, List<String>>*/ classMethods = new HashMap(); for (int i = 0; i < methods.length; i++) { methodNames.add(methods[i].getElementName()); List methodList = (List) classMethods.get(methods[i].getDeclaringType().getFullyQualifiedName()); if (null == methodList) { methodList = new ArrayList(); classMethods.put(methods[i].getDeclaringType().getFullyQualifiedName(), methodList); } methodList.add(methods[i].getElementName()); } IType[] types = (IType[]) typesSet.toArray(new IType[typesSet.size()]); List typeNames = new ArrayList(); for (int i = 0; i < types.length; i++) { typeNames.add(types[i].getFullyQualifiedName()); } String name = typeNames.get(0).toString() + "." + methodNames.get(0).toString(); final String complianceLevel = annotationType != null ? annotationType : getQuickComplianceLevel(types); ILaunchConfigurationWorkingCopy workingCopy = createLaunchConfiguration(ijp.getProject(), name, runInfo); workingCopy.setAttribute(TestNGLaunchConfigurationConstants.CLASS_TEST_LIST, typeNames); workingCopy.setAttribute(TestNGLaunchConfigurationConstants.METHOD_TEST_LIST, methodNames); workingCopy.setAttribute( TestNGLaunchConfigurationConstants.PACKAGE_TEST_LIST, EMPTY_ARRAY_PARAM); workingCopy.setAttribute(TestNGLaunchConfigurationConstants.TYPE, LaunchType.METHOD.ordinal()); workingCopy.setAttribute( TestNGLaunchConfigurationConstants.ALL_METHODS_LIST, ConfigurationHelper.toClassMethodsMap(classMethods)); workingCopy.setAttribute(TestNGLaunchConfigurationConstants.PARAMS, solveParameters(methods)); workingCopy.setAttribute( TestNGLaunchConfigurationConstants.TESTNG_COMPLIANCE_LEVEL_ATTR, complianceLevel); if (runInfo != null) { // set the class and method // set any jvm args String jargs = runInfo.getJvmArgs(); if (jargs != null) workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, jargs); setFailedTestsJvmArg(runInfo.getTestDescription(), workingCopy); } runConfig(workingCopy, runMode); }