Skip to content

Commit

Permalink
Fix the bug that run tests from workspace folder will run all the tes…
Browse files Browse the repository at this point in the history
…ts in the workspace (#542)
  • Loading branch information
jdneo authored Dec 26, 2018
1 parent 367a422 commit 810605c
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ public static List<TestItem> searchTestItems(List<Object> arguments, IProgressMo
* @throws CoreException
* @throws OperationCanceledException
* @throws InterruptedException
* @throws URISyntaxException
*/
public static List<TestItem> searchAllTestItems(List<Object> arguments, IProgressMonitor monitor)
throws CoreException, OperationCanceledException, InterruptedException {
throws CoreException, OperationCanceledException, InterruptedException, URISyntaxException {
final List<TestItem> searchResult = new LinkedList<>();

if (arguments == null || arguments.size() == 0) {
Expand Down Expand Up @@ -228,17 +229,17 @@ private static boolean isInTestScope(IJavaElement element) throws JavaModelExcep
return false;
}

private static IJavaSearchScope createSearchScope(SearchTestItemParams params) throws JavaModelException {
private static IJavaSearchScope createSearchScope(SearchTestItemParams params)
throws JavaModelException, URISyntaxException {
switch (params.getLevel()) {
case ROOT:
final IJavaProject[] projects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot())
.getJavaProjects();
return SearchEngine.createJavaSearchScope(projects, IJavaSearchScope.SOURCES);
case FOLDER:

final IJavaProject[] javaProjects = JavaCore.create(JDTUtils.findFolder(params.getUri())).getJavaModel()
.getJavaProjects();
return SearchEngine.createJavaSearchScope(javaProjects, IJavaSearchScope.SOURCES);
final Set<IJavaProject> projectSet = ProjectUtils.parseProjects(new URI(params.getUri()));
return SearchEngine.createJavaSearchScope(projectSet.toArray(new IJavaElement[projectSet.size()]),
IJavaSearchScope.SOURCES);
case PACKAGE:
final IJavaElement packageElement = JDTUtils.resolvePackage(params.getUri());
return SearchEngine.createJavaSearchScope(new IJavaElement[] { packageElement },
Expand Down

0 comments on commit 810605c

Please sign in to comment.