diff --git a/viewer/META-INF/MANIFEST.MF b/viewer/META-INF/MANIFEST.MF index 43d907c..1318465 100644 --- a/viewer/META-INF/MANIFEST.MF +++ b/viewer/META-INF/MANIFEST.MF @@ -30,14 +30,14 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)", org.apache.commons.lang3, com._1c.g5.v8.dt.bsl.core;bundle-version="6.0.300", org.eclipse.handly;bundle-version="1.5.0", - com._1c.g5.v8.dt.lcore;bundle-version="3.1.900" + com._1c.g5.v8.dt.lcore;bundle-version="3.1.900", + com.google.gson Bundle-RequiredExecutionEnvironment: JavaSE-11 Import-Package: com._1c.g5.v8.dt.bm.index.emf, com._1c.g5.v8.dt.bsl.model, com._1c.g5.v8.dt.stacktraces.model, com._1c.g5.wiring, com.google.common.base, - com.google.gson;version="2.8.2", javax.xml.parsers, lombok;resolution:=optional, lombok.experimental;resolution:=optional, diff --git a/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleItem.java b/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleItem.java new file mode 100644 index 0000000..9cda697 --- /dev/null +++ b/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleItem.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2023 BIA-Technologies Limited Liability Company. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +package ru.biatech.edt.junit.launcher.lifecycle; + +import lombok.Getter; +import lombok.Setter; +import org.eclipse.debug.core.ILaunch; + +import java.time.Instant; + +@Getter +public class LifecycleItem { + private final ILaunch testLaunch; + @Setter + private ILaunch mainLaunch; + private final String name; + private boolean active = true; + private Instant start; + private Instant end; + + public LifecycleItem(ILaunch testLaunch, String name) { + this.testLaunch = testLaunch; + this.name = name; + } + + public void onStop() { + active = true; + end = Instant.now(); + } + + public void onStart() { + active = true; + start = Instant.now(); + } +} diff --git a/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleListener.java b/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleListener.java index e206f73..4066cee 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleListener.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleListener.java @@ -19,5 +19,5 @@ import org.eclipse.debug.core.ILaunch; public interface LifecycleListener { - void handle(int eventType, ILaunch launch); + void handle(int eventType, LifecycleItem item); } diff --git a/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleMonitor.java b/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleMonitor.java index 29d7d69..88f25c2 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleMonitor.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/launcher/lifecycle/LifecycleMonitor.java @@ -17,7 +17,6 @@ package ru.biatech.edt.junit.launcher.lifecycle; import com.google.common.base.Strings; -import lombok.Getter; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; import org.eclipse.debug.core.DebugEvent; @@ -32,7 +31,6 @@ import ru.biatech.edt.junit.launcher.v8.LaunchHelper; import ru.biatech.edt.junit.ui.JUnitMessages; -import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -76,8 +74,8 @@ public void removeTerminated() { for (var item : monitor.monitoringItems.values()) { if (!item.isActive()) { - removed.add(item.mainLaunch); - removed.add(item.testLaunch); + removed.add(item.getMainLaunch()); + removed.add(item.getTestLaunch()); } } @@ -93,34 +91,32 @@ private void debug(String message) { TestViewerPlugin.log().debug(message); } - private void riseEvent(int eventType, MonitoringItem item) { - TestViewerPlugin.log().debug("Launch event: {0} for {1}", LifecycleEvent.getPresent(eventType), item.name); + private void riseEvent(int eventType, LifecycleItem item) { + TestViewerPlugin.log().debug("Launch event: {0} for {1}", LifecycleEvent.getPresent(eventType), item.getName()); if (LifecycleEvent.isStop(eventType)) { try { - item.testLaunch.terminate(); + item.getTestLaunch().terminate(); } catch (DebugException e) { TestViewerPlugin.log().logError("Terminate test launch", e); } } - listeners.forEach(l -> l.handle(eventType, item.mainLaunch)); + listeners.forEach(l -> l.handle(eventType, item)); } - private void onItemStart(MonitoringItem item) { - item.active = true; - item.start = Instant.now(); + private void onItemStart(LifecycleItem item) { + item.onStart(); riseEvent(LifecycleEvent.START, item); removeTerminated(); } - private void onItemStop(MonitoringItem item, int eventType) { - item.active = false; - item.end = Instant.now(); + private void onItemStop(LifecycleItem item, int eventType) { + item.onStop(); riseEvent(eventType, item); } private static class LaunchMonitor implements ILaunchListener, IDebugEventSetListener { ReentrantLock lock = new ReentrantLock(); - Map monitoringItems = new HashMap<>(); + Map monitoringItems = new HashMap<>(); @Override public void handleDebugEvents(DebugEvent[] events) { @@ -136,9 +132,8 @@ public void handleDebugEvents(DebugEvent[] events) { if (monitoringItems.containsKey(launch)) { var item = monitoringItems.get(launch); handleProcesses(item); - if (item.active) { - debug("Finish " + item.name); - item.active = false; + if (item.isActive()) { + debug("Finish " + item.getName()); onTerminate(item, process); } } @@ -156,8 +151,8 @@ public void launchRemoved(ILaunch launch) { if (monitoringItems.containsKey(launch)) { var item = monitoringItems.get(launch); handleProcesses(item); - if (item.active) { - debug("canceled " + item.name); + if (item.isActive()) { + debug("canceled " + item.getName()); onItemStop(item, LifecycleEvent.CANCELED); } } @@ -172,16 +167,14 @@ public void launchAdded(ILaunch launch) { var configuration = launch.getLaunchConfiguration(); if (LaunchHelper.isRunTestConfiguration(configuration)) { - var item = new MonitoringItem(); - item.testLaunch = launch; - item.name = configuration.getName(); + var item = new LifecycleItem(launch, configuration.getName()); monitoringItems.put(launch, item); onItemStart(item); } else if (LaunchHelper.isOnecConfiguration(configuration) && !Strings.isNullOrEmpty(LaunchConfigurationAttributes.getTestKind(configuration))) { var name = configuration.getName(); for (var item : monitoringItems.values()) { - if (name.contains(item.name)) { - item.mainLaunch = launch; + if (name.contains(item.getName())) { + item.setMainLaunch(launch); handleProcesses(item); monitoringItems.put(launch, item); break; @@ -199,12 +192,15 @@ public void launchChanged(ILaunch launch) { } } - private void handleProcesses(MonitoringItem item) { - if (item.testLaunch.getProcesses().length < item.mainLaunch.getProcesses().length) { - var processes = new HashSet<>(List.of(item.testLaunch.getProcesses())); - for (var process : item.mainLaunch.getProcesses()) { + private void handleProcesses(LifecycleItem item) { + if (item.getMainLaunch() == null) { + return; + } + if (item.getTestLaunch().getProcesses().length < item.getMainLaunch().getProcesses().length) { + var processes = new HashSet<>(List.of(item.getTestLaunch().getProcesses())); + for (var process : item.getMainLaunch().getProcesses()) { if (!processes.contains(process)) { - item.testLaunch.addProcess(process); + item.getTestLaunch().addProcess(process); } } } @@ -218,13 +214,13 @@ private void onLaunchEvent(String eventName, ILaunch launch) { debug(message); } - private void onTerminate(MonitoringItem item, IProcess process) { + private void onTerminate(LifecycleItem item, IProcess process) { int exitCode = 0; try { exitCode = process.getExitValue(); } catch (DebugException e) { /* do nothing*/ } if (exitCode != 0) { - TestViewerPlugin.log().warning(JUnitMessages.JUnitLaunchListener_ProcessError, item.name, process.getLabel(), exitCode); + TestViewerPlugin.log().warning(JUnitMessages.JUnitLaunchListener_ProcessError, item.getName(), process.getLabel(), exitCode); onItemStop(item, LifecycleEvent.FINISHED_WITH_ERROR); } else { onItemStop(item, LifecycleEvent.FINISHED); @@ -232,13 +228,4 @@ private void onTerminate(MonitoringItem item, IProcess process) { } } - @Getter - private static class MonitoringItem { - private ILaunch testLaunch; - private ILaunch mainLaunch; - private String name; - private boolean active = true; - private Instant start; - private Instant end; - } } diff --git a/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/LaunchConfigurationAttributes.java b/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/LaunchConfigurationAttributes.java index cfe9d0f..2e3ccd2 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/LaunchConfigurationAttributes.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/LaunchConfigurationAttributes.java @@ -75,6 +75,12 @@ public static void setTestMethods(ILaunchConfigurationWorkingCopy configuration, configuration.setAttribute(TEST_FULL_NAME, value); } + public static void clearFilter(ILaunchConfigurationWorkingCopy configuration) { + configuration.removeAttribute(TEST_FULL_NAME); + configuration.removeAttribute(TEST_MODULE); + configuration.removeAttribute(TEST_EXTENSION); + } + public static List getTestMethods(ILaunchConfiguration configuration) { try { return configuration.getAttribute(TEST_FULL_NAME, (List) null); @@ -91,7 +97,7 @@ public static String getTestModuleName(ILaunchConfiguration configuration) { return getAttribute(configuration, TEST_MODULE); } - public static String getTestKind(ILaunchConfiguration configuration){ + public static String getTestKind(ILaunchConfiguration configuration) { return getAttribute(configuration, ATTR_TEST_RUNNER_KIND); } @@ -102,4 +108,12 @@ public static String getAttribute(ILaunchConfiguration configuration, String att throw new RuntimeException(e); } } + + public static String getWorkPath(ILaunchConfiguration configuration) { + return getAttribute(configuration, WORK_PATH); + } + + public static String getProject(ILaunchConfiguration configuration) { + return getAttribute(configuration, PROJECT); + } } \ No newline at end of file diff --git a/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/LaunchHelper.java b/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/LaunchHelper.java index 3ef4d6c..01e778a 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/LaunchHelper.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/LaunchHelper.java @@ -140,8 +140,8 @@ public List getTestModules(IExtensionProject extensionProject) { .collect(Collectors.toList()); } - public Path getWorkPath(ILaunchConfiguration configuration) { - var reportLocation = Platform.getStateLocation(TestViewerPlugin.getBundleContext().getBundle()).append(configuration.getName()); + public Path getWorkPath(String name) { + var reportLocation = Platform.getStateLocation(TestViewerPlugin.getBundleContext().getBundle()).append(name); var path = reportLocation.toFile().toPath(); try { Files.createDirectories(path); @@ -165,7 +165,7 @@ public void runTestMethod(String moduleName, String methodName, String launchMod TestViewerPlugin.log().logError(e); return; } - + LaunchConfigurationAttributes.clearFilter(copy); LaunchConfigurationAttributes.setTestMethods(copy, List.of(methodFullName)); DebugUITools.launch(copy, launchMode); } @@ -181,6 +181,11 @@ public ITestKind getTestRunnerKind(ILaunchConfiguration launchConfiguration) { return ITestKind.NULL; } + public Path getReportPath(ILaunchConfiguration configuration) { + var workPath = LaunchConfigurationAttributes.getWorkPath(configuration); + return Path.of(workPath, REPORT_FILE_NAME); + } + public IV8Project getProject(ILaunchConfiguration configuration) { // TODO // try { diff --git a/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/RerunHelper.java b/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/RerunHelper.java index 1c3c41f..6e6f62a 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/RerunHelper.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/launcher/v8/RerunHelper.java @@ -17,79 +17,89 @@ package ru.biatech.edt.junit.launcher.v8; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunch; +import lombok.SneakyThrows; import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.DebugUITools; import ru.biatech.edt.junit.TestViewerPlugin; -import ru.biatech.edt.junit.kinds.IUnitLauncher; import ru.biatech.edt.junit.model.TestRunSession; import java.util.List; public class RerunHelper { - public static ILaunchConfiguration getLaunchConfiguration(TestRunSession testRunSession) { - if (testRunSession != null) { - ILaunch launch = testRunSession.getLaunch(); - if (launch != null) { - // run the selected test using the previous launch configuration - return launch.getLaunchConfiguration(); - } - } - return null; - } - public static boolean isRerunConfiguration(ILaunchConfiguration launchConfiguration) { + public static final String PREFIX_RERUN = "Rerun "; + + public static boolean isNotRerunConfiguration(ILaunchConfiguration launchConfiguration) { var attribute = LaunchConfigurationAttributes.getTestMethods(launchConfiguration); - return attribute != null; + return attribute == null; } - public static void rerun(TestRunSession testRunSession, String configName, List testClasses) throws CoreException { - if (testRunSession == null || testRunSession.getLaunch() == null) { + @SneakyThrows + public static void rerunTest(TestRunSession session, String testClassName, String launchMode) { + if (isBadSession(session)) { return; } - rerun(testRunSession, configName, testClasses, testRunSession.getLaunch().getLaunchMode()); + + var configName = PREFIX_RERUN + testClassName; + rerunTests(session, List.of(testClassName), configName, launchMode); } - public static void rerun(TestRunSession testRunSession, String configName, List testClasses, String launchMode) throws CoreException { - if (!canRerun(testRunSession, testClasses)) { + @SneakyThrows + public static void rerun(TestRunSession session) { + if (isBadSession(session)) { return; } - ILaunchConfiguration launchConfiguration = RerunHelper.getLaunchConfiguration(testRunSession); - ILaunchConfigurationWorkingCopy tmp = launchConfiguration.copy(configName); - tmp.setAttribute(LaunchConfigurationAttributes.TEST_FULL_NAME, testClasses); //$NON-NLS-1$ - launch(testRunSession, tmp, launchMode); - } - public static void launch(TestRunSession testRunSession, ILaunchConfiguration launchConfiguration, String launchMode) { - ILaunchConfigurationWorkingCopy workingCopy; - if (launchConfiguration.isWorkingCopy()) { - workingCopy = (ILaunchConfigurationWorkingCopy) launchConfiguration; - } else { - try { - workingCopy = launchConfiguration.getWorkingCopy(); - } catch (CoreException e) { - TestViewerPlugin.log().logError(e); - return; - } + var configuration = session.getLaunch().getLaunchConfiguration(); + + if (isNotRerunConfiguration(configuration)) { + var configName = PREFIX_RERUN + configuration.getName(); + configuration = configuration.copy(configName); } - launch(testRunSession, workingCopy, launchMode); + DebugUITools.launch(configuration, session.getLaunch().getLaunchMode()); } - public static void launch(TestRunSession testRunSession, ILaunchConfigurationWorkingCopy launchConfiguration, String launchMode) { - IUnitLauncher launcherKind = testRunSession.getTestRunnerKind().getLauncher(); - launcherKind.configure(launchConfiguration, launchConfiguration); - DebugUITools.launch(launchConfiguration, launchMode); + @SneakyThrows + public static void rerunFailures(TestRunSession session) { + if (isBadSession(session)) { + return; + } + var configuration = session.getLaunch().getLaunchConfiguration(); + var failedTest = session.getAllFailedTestNames(); + + var configName = configuration.getName(); + if (isNotRerunConfiguration(configuration)) { + configName = PREFIX_RERUN + configName; + } + + rerunTests(session, failedTest, configName, session.getLaunch().getLaunchMode()); } - private static boolean canRerun(TestRunSession testRunSession, List testClasses) { - if (testClasses.isEmpty()) { - return false; + @SneakyThrows + private static boolean isBadSession(TestRunSession session) { + if (session == null || session.getLaunch() == null) { + return true; + } + var configuration = session.getLaunch().getLaunchConfiguration(); + + if (!LaunchHelper.isRunTestConfiguration(configuration)) { + TestViewerPlugin.log().logError("Некорректная конфигурация запуска. Должна быть передана конфигурация запуска тестов, а пришла " + configuration.getType().getIdentifier()); + return true; } - ILaunchConfiguration launchConfiguration = RerunHelper.getLaunchConfiguration(testRunSession); - return launchConfiguration != null; + return false; } + @SneakyThrows + private static void rerunTests(TestRunSession session, List tests, String configName, String launchMode) { + if (tests == null || tests.isEmpty()) { + return; + } + + var configurationCopy = session.getLaunch().getLaunchConfiguration().copy(configName); + LaunchConfigurationAttributes.setTestMethods(configurationCopy, tests); + + DebugUITools.launch(configurationCopy, launchMode); + + } } diff --git a/viewer/src/main/java/ru/biatech/edt/junit/model/JUnitModel.java b/viewer/src/main/java/ru/biatech/edt/junit/model/JUnitModel.java index 61414ad..ed41357 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/model/JUnitModel.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/model/JUnitModel.java @@ -30,11 +30,12 @@ import ru.biatech.edt.junit.JUnitCore; import ru.biatech.edt.junit.JUnitPreferencesConstants; import ru.biatech.edt.junit.TestViewerPlugin; -import ru.biatech.edt.junit.launcher.v8.LaunchConfigurationAttributes; -import ru.biatech.edt.junit.launcher.v8.LaunchHelper; import ru.biatech.edt.junit.launcher.lifecycle.LifecycleEvent; +import ru.biatech.edt.junit.launcher.lifecycle.LifecycleItem; import ru.biatech.edt.junit.launcher.lifecycle.LifecycleListener; import ru.biatech.edt.junit.launcher.lifecycle.LifecycleMonitor; +import ru.biatech.edt.junit.launcher.v8.LaunchConfigurationAttributes; +import ru.biatech.edt.junit.launcher.v8.LaunchHelper; import ru.biatech.edt.junit.model.serialize.Serializer; import ru.biatech.edt.junit.ui.JUnitMessages; @@ -87,9 +88,9 @@ public static void importTestRunSession(String url, String defaultProjectName, I * Starts the model (called by the {@link JUnitCore} on startup). */ public void start() { - LifecycleMonitor.addListener(lifecycleListener = (eventType, launch) -> { + LifecycleMonitor.addListener(lifecycleListener = (eventType, item) -> { if (LifecycleEvent.isFinished(eventType)) { - JUnitModel.loadTestReport(launch); + JUnitModel.loadTestReport(item); } }); addTestRunSessionListener(new TestRunSessionListener()); @@ -191,28 +192,30 @@ private void notifyTestRunSessionAdded(TestRunSession testRunSession) { fTestRunSessionListeners.forEach(it -> it.sessionAdded(testRunSession)); } - public static void loadTestReport(ILaunch launch) { + public static void loadTestReport(LifecycleItem item) { TestViewerPlugin.log().debug(JUnitMessages.JUnitModel_LoadReport); try { + var launch = item.getMainLaunch(); + var configuration = launch.getLaunchConfiguration(); - String workPath = configuration.getAttribute(LaunchConfigurationAttributes.WORK_PATH, (String) null); - String project = configuration.getAttribute(LaunchConfigurationAttributes.PROJECT, (String) null); + var project = LaunchConfigurationAttributes.getProject(configuration); + + var reportPath = LaunchHelper.getReportPath(configuration); + TestViewerPlugin.log().debug(JUnitMessages.JUnitModel_ReportFile, reportPath.toAbsolutePath()); - File file = new File(workPath, LaunchHelper.REPORT_FILE_NAME); //$NON-NLS-1$ - TestViewerPlugin.log().debug(JUnitMessages.JUnitModel_ReportFile, file.getAbsolutePath()); - if (!file.exists()) { + if (!Files.exists(reportPath)) { TestViewerPlugin.log().logError(JUnitMessages.JUnitModel_ReportFileNotFound); return; } - TestRunSession session = JUnitModel.importTestRunSession(file, project); + var session = JUnitModel.importTestRunSession(reportPath.toFile(), project); assert session != null; - session.setLaunch(launch); + session.setLaunch(item.getTestLaunch()); TestViewerPlugin.ui().asyncShowTestRunnerViewPart(); - Files.deleteIfExists(file.toPath()); + Files.deleteIfExists(reportPath); } catch (CoreException | IOException e) { TestViewerPlugin.log().logError(JUnitMessages.JUnitModel_UnknownErrorOnReportLoad, e); } diff --git a/viewer/src/main/java/ru/biatech/edt/junit/model/TestRunSession.java b/viewer/src/main/java/ru/biatech/edt/junit/model/TestRunSession.java index c1200c8..0e631e2 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/model/TestRunSession.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/model/TestRunSession.java @@ -36,7 +36,9 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; /** @@ -210,9 +212,9 @@ public ITestRunSession getTestRunSession() { return this; } - public void setLaunch(ILaunch pLaunch) { - launch = pLaunch; - var launchConfiguration = launch.getLaunchConfiguration(); + public void setLaunch(ILaunch launch) { + this.launch = launch; + var launchConfiguration = this.launch.getLaunchConfiguration(); if (launchConfiguration != null) { testRunName = launchConfiguration.getName(); testRunnerKind = LaunchHelper.getTestRunnerKind(launchConfiguration); @@ -344,6 +346,14 @@ public ITestCaseElement[] getAllFailedTestElements() { return failures.toArray(ITestCaseElement[]::new); } + public List getAllFailedTestNames() { + var failures = new ArrayList(); + addFailures(failures, getTestRoot()); + return failures.stream() + .map(ITestCaseElement::getTestClassName) + .collect(Collectors.toList()); + } + private void addFailures(ArrayList failures, ITestElement testElement) { var testResult = testElement.getTestResult(true); if (testElement instanceof ITestCaseElement && (testResult == TestResult.ERROR || testResult == TestResult.FAILURE)) { diff --git a/viewer/src/main/java/ru/biatech/edt/junit/ui/report/TestRunnerViewPart.java b/viewer/src/main/java/ru/biatech/edt/junit/ui/report/TestRunnerViewPart.java index 37280ef..b1d32f5 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/ui/report/TestRunnerViewPart.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/ui/report/TestRunnerViewPart.java @@ -40,9 +40,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ILock; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; @@ -50,8 +47,6 @@ import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; @@ -97,8 +92,6 @@ import ru.biatech.edt.junit.JUnitPreferencesConstants; import ru.biatech.edt.junit.TestViewerPlugin; import ru.biatech.edt.junit.kinds.ITestKind; -import ru.biatech.edt.junit.launcher.v8.LaunchConfigurationAttributes; -import ru.biatech.edt.junit.launcher.v8.RerunHelper; import ru.biatech.edt.junit.model.ITestCaseElement; import ru.biatech.edt.junit.model.ITestRunSessionListener; import ru.biatech.edt.junit.model.ITestSessionListener; @@ -114,6 +107,8 @@ import ru.biatech.edt.junit.ui.report.actions.ActivateOnErrorAction; import ru.biatech.edt.junit.ui.report.actions.FailuresOnlyFilterAction; import ru.biatech.edt.junit.ui.report.actions.IgnoredOnlyFilterAction; +import ru.biatech.edt.junit.ui.report.actions.RerunLastAction; +import ru.biatech.edt.junit.ui.report.actions.RerunLastFailedFirstAction; import ru.biatech.edt.junit.ui.report.actions.ScrollLockAction; import ru.biatech.edt.junit.ui.report.actions.ShowNextFailureAction; import ru.biatech.edt.junit.ui.report.actions.ShowPreviousFailureAction; @@ -129,9 +124,7 @@ import java.lang.reflect.InvocationTargetException; import java.text.MessageFormat; import java.text.NumberFormat; -import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; /** * A ViewPart that shows the results of a test run. @@ -147,8 +140,8 @@ public class TestRunnerViewPart extends ViewPart { public static final int VIEW_ORIENTATION_VERTICAL = 0; public static final int VIEW_ORIENTATION_HORIZONTAL = 1; public static final int VIEW_ORIENTATION_AUTOMATIC = 2; - private static final String RERUN_LAST_COMMAND = "ru.biatech.edt.junit.junitShortcut.rerunLast"; //$NON-NLS-1$ - private static final String RERUN_FAILED_FIRST_COMMAND = "ru.biatech.edt.junit.junitShortcut.rerunFailedFirst"; //$NON-NLS-1$ + public static final String RERUN_LAST_COMMAND = "ru.biatech.edt.junit.junitShortcut.rerunLast"; //$NON-NLS-1$ + public static final String RERUN_FAILED_FIRST_COMMAND = "ru.biatech.edt.junit.junitShortcut.rerunFailedFirst"; //$NON-NLS-1$ /** * @since 3.5 @@ -214,30 +207,6 @@ public class TestRunnerViewPart extends ViewPart { private JUnitIsRunningJob fJUnitIsRunningJob; private ILock fJUnitIsRunningLock; private final IPartListener2 fPartListener = new IPartListener2() { - @Override - public void partActivated(IWorkbenchPartReference ref) { - } - - @Override - public void partBroughtToTop(IWorkbenchPartReference ref) { - } - - @Override - public void partInputChanged(IWorkbenchPartReference ref) { - } - - @Override - public void partClosed(IWorkbenchPartReference ref) { - } - - @Override - public void partDeactivated(IWorkbenchPartReference ref) { - } - - @Override - public void partOpened(IWorkbenchPartReference ref) { - } - @Override public void partVisible(IWorkbenchPartReference ref) { if (getSite().getId().equals(ref.getId())) { @@ -302,67 +271,6 @@ public void stopTest() { } } - /** - * Stops the currently running test and shuts down the RemoteTestRunner - */ - public void rerunTestRun() { - if (lastLaunchIsKeptAlive()) { - // prompt for terminating the existing run - var answer = MessageDialog.openQuestion(getSite().getShell(), - JUnitMessages.TestRunnerViewPart_terminate_title, - JUnitMessages.TestRunnerViewPart_terminate_message); - if (answer) { - stopTest(); // TODO: wait for termination - } - } - - ILaunchConfiguration launchConfiguration; - ILaunch launch; - if (fTestRunSession == null - || ((launch = fTestRunSession.getLaunch()) == null) - || ((launchConfiguration = launch.getLaunchConfiguration()) == null)) { - return; - } - - ILaunchConfiguration configuration = prepareLaunchConfigForRelaunch(launchConfiguration); - RerunHelper.launch(fTestRunSession, configuration, launch.getLaunchMode()); - } - - public void rerunTest(String className, String launchMode) { - try { - String configName = MessageFormat.format(JUnitMessages.TestRunnerViewPart_configName, className); - RerunHelper.rerun(fTestRunSession, configName, List.of(className), launchMode); - return; - } catch (CoreException e) { - ErrorDialog.openError(getSite().getShell(), JUnitMessages.TestRunnerViewPart_error_cannotrerun, e.getMessage(), e.getStatus()); - } - MessageDialog.openInformation(getSite().getShell(), - JUnitMessages.TestRunnerViewPart_cannotrerun_title, - JUnitMessages.TestRunnerViewPart_cannotrerurn_message); - } - - public void rerunTestFailedFirst() { - ILaunchConfiguration launchConfiguration = RerunHelper.getLaunchConfiguration(fTestRunSession); - if (launchConfiguration != null) { - try { - String configName; - if (RerunHelper.isRerunConfiguration(launchConfiguration)) { - configName = launchConfiguration.getName(); - } else { - configName = MessageFormat.format(JUnitMessages.TestRunnerViewPart_rerunFailedFirstLaunchConfigName, launchConfiguration.getName()); - } - RerunHelper.rerun(fTestRunSession, configName, createFailureNamesFile()); - return; - } catch (CoreException e) { - ErrorDialog.openError(getSite().getShell(), JUnitMessages.TestRunnerViewPart_error_cannotrerun, e.getMessage(), e.getStatus()); - } - - MessageDialog.openInformation(getSite().getShell(), - JUnitMessages.TestRunnerViewPart_cannotrerun_title, - JUnitMessages.TestRunnerViewPart_cannotrerurn_message); - } - } - public void selectNextFailure() { fTestViewer.selectFailure(true); } @@ -581,28 +489,6 @@ private void updateNextPreviousActions() { fPreviousAction.setEnabled(hasErrorsOrFailures); } - private ILaunchConfiguration prepareLaunchConfigForRelaunch(ILaunchConfiguration configuration) { - try { - if (RerunHelper.isRerunConfiguration(configuration)) { - String configName = MessageFormat.format(JUnitMessages.TestRunnerViewPart_configName, configuration.getName()); - ILaunchConfigurationWorkingCopy tmp = configuration.copy(configName); - LaunchConfigurationAttributes.clearTestMethods(tmp); - return tmp; - } - } catch (CoreException e) { - // fall through - } - return configuration; - } - - private List createFailureNamesFile() throws CoreException { - return Arrays.stream(fTestRunSession.getAllFailedTestElements()) - .filter(ITestCaseElement.class::isInstance) - .map(ITestCaseElement.class::cast) - .map(ITestCaseElement::getTestClassName) - .collect(Collectors.toList()); - } - private void selectFirstFailure() { fTestViewer.selectFirstFailure(); } @@ -1012,7 +898,7 @@ private void configureToolBar() { fStopAction = new StopAction(); fStopAction.setEnabled(false); - fRerunLastTestAction = new RerunLastAction(); + fRerunLastTestAction = new RerunLastAction(this); IHandlerService handlerService = getSite().getWorkbenchWindow().getService(IHandlerService.class); IHandler handler = new AbstractHandler() { @Override @@ -1028,7 +914,7 @@ public boolean isEnabled() { }; fRerunLastActivation = handlerService.activateHandler(RERUN_LAST_COMMAND, handler); - fRerunFailedFirstAction = new RerunLastFailedFirstAction(); + fRerunFailedFirstAction = new RerunLastFailedFirstAction(this); handler = new AbstractHandler() { @Override public Object execute(ExecutionEvent event) { @@ -1413,36 +1299,6 @@ public void run() { } } - private class RerunLastAction extends Action { - public RerunLastAction() { - setText(JUnitMessages.TestRunnerViewPart_rerunaction_label); - setToolTipText(JUnitMessages.TestRunnerViewPart_rerunaction_tooltip); - TestViewerPlugin.ui().setLocalImageDescriptors(this, "relaunch.png"); //$NON-NLS-1$ - setEnabled(false); - setActionDefinitionId(RERUN_LAST_COMMAND); - } - - @Override - public void run() { - rerunTestRun(); - } - } - - private class RerunLastFailedFirstAction extends Action { - public RerunLastFailedFirstAction() { - setText(JUnitMessages.TestRunnerViewPart_rerunfailuresaction_label); - setToolTipText(JUnitMessages.TestRunnerViewPart_rerunfailuresaction_tooltip); - TestViewerPlugin.ui().setLocalImageDescriptors(this, "relaunchf.png"); //$NON-NLS-1$ - setEnabled(false); - setActionDefinitionId(RERUN_FAILED_FIRST_COMMAND); - } - - @Override - public void run() { - rerunTestFailedFirst(); - } - } - public class ReportSettings { // TODO В будущем сделать рефакторинг вынеся в самостоятельный класс private static final String TAG_RATIO = "ratio"; //$NON-NLS-1$ diff --git a/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunAction.java b/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunAction.java index 7d6dddf..7b59107 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunAction.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunAction.java @@ -20,6 +20,7 @@ import org.eclipse.jface.action.Action; import org.eclipse.ui.PlatformUI; import ru.biatech.edt.junit.TestViewerPlugin; +import ru.biatech.edt.junit.launcher.v8.RerunHelper; import ru.biatech.edt.junit.ui.IJUnitHelpContextIds; import ru.biatech.edt.junit.ui.report.TestRunnerViewPart; @@ -54,6 +55,6 @@ public RerunAction(String actionName, TestRunnerViewPart runner, String classNam @Override public void run() { - fTestRunner.rerunTest(fClassName, fLaunchMode); + RerunHelper.rerunTest(fTestRunner.getTestRunSession(), fClassName, fLaunchMode); } } diff --git a/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunLastAction.java b/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunLastAction.java new file mode 100644 index 0000000..f39c562 --- /dev/null +++ b/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunLastAction.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2023 BIA-Technologies Limited Liability Company. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +package ru.biatech.edt.junit.ui.report.actions; + +import org.eclipse.jface.action.Action; +import ru.biatech.edt.junit.TestViewerPlugin; +import ru.biatech.edt.junit.launcher.v8.RerunHelper; +import ru.biatech.edt.junit.ui.JUnitMessages; +import ru.biatech.edt.junit.ui.report.TestRunnerViewPart; + +public class RerunLastAction extends Action { + private final TestRunnerViewPart testRunnerViewPart; + + public RerunLastAction(TestRunnerViewPart testRunnerViewPart) { + this.testRunnerViewPart = testRunnerViewPart; + setText(JUnitMessages.TestRunnerViewPart_rerunaction_label); + setToolTipText(JUnitMessages.TestRunnerViewPart_rerunaction_tooltip); + TestViewerPlugin.ui().setLocalImageDescriptors(this, "relaunch.png"); //$NON-NLS-1$ + setEnabled(false); + setActionDefinitionId(TestRunnerViewPart.RERUN_LAST_COMMAND); + } + + @Override + public void run() { + RerunHelper.rerun(testRunnerViewPart.getTestRunSession()); + } +} diff --git a/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunLastFailedFirstAction.java b/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunLastFailedFirstAction.java new file mode 100644 index 0000000..20d1a8d --- /dev/null +++ b/viewer/src/main/java/ru/biatech/edt/junit/ui/report/actions/RerunLastFailedFirstAction.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2023 BIA-Technologies Limited Liability Company. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +package ru.biatech.edt.junit.ui.report.actions; + +import org.eclipse.jface.action.Action; +import ru.biatech.edt.junit.TestViewerPlugin; +import ru.biatech.edt.junit.launcher.v8.RerunHelper; +import ru.biatech.edt.junit.ui.JUnitMessages; +import ru.biatech.edt.junit.ui.report.TestRunnerViewPart; + +public class RerunLastFailedFirstAction extends Action { + private final TestRunnerViewPart testRunnerViewPart; + + public RerunLastFailedFirstAction(TestRunnerViewPart testRunnerViewPart) { + this.testRunnerViewPart = testRunnerViewPart; + setText(JUnitMessages.TestRunnerViewPart_rerunfailuresaction_label); + setToolTipText(JUnitMessages.TestRunnerViewPart_rerunfailuresaction_tooltip); + TestViewerPlugin.ui().setLocalImageDescriptors(this, "relaunchf.png"); //$NON-NLS-1$ + setEnabled(false); + setActionDefinitionId(TestRunnerViewPart.RERUN_FAILED_FIRST_COMMAND); + } + + @Override + public void run() { + RerunHelper.rerunFailures(testRunnerViewPart.getTestRunSession()); + } +} diff --git a/viewer/src/main/java/ru/biatech/edt/junit/yaxunit/LaunchSettings.java b/viewer/src/main/java/ru/biatech/edt/junit/yaxunit/LaunchSettings.java new file mode 100644 index 0000000..6b0dfd1 --- /dev/null +++ b/viewer/src/main/java/ru/biatech/edt/junit/yaxunit/LaunchSettings.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2023 BIA-Technologies Limited Liability Company. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +package ru.biatech.edt.junit.yaxunit; + +import com.google.common.base.Strings; +import com.google.gson.annotations.Expose; +import lombok.Getter; +import org.eclipse.debug.core.ILaunchConfiguration; +import ru.biatech.edt.junit.launcher.v8.LaunchConfigurationAttributes; +import ru.biatech.edt.junit.launcher.v8.LaunchHelper; +import ru.biatech.edt.junit.v8utils.Projects; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@Getter +public class LaunchSettings { + String name; + String workPath; + @Expose + String reportPath; + @Expose + String reportFormat = Launcher.REPORT_FORMAT; + @Expose + boolean closeAfterTests = true; + @Expose + Filter filter; + String extensionName; + + public static class Filter { + @Expose + List extensions = new ArrayList<>();; + @Expose + List modules = new ArrayList<>(); + @Expose + List tests = new ArrayList<>(); + + public void addModule(String moduleName) { + if (!Strings.isNullOrEmpty(moduleName)) { + modules.add(moduleName); + } + } + + public void addExtension(String extensionName) { + if (!Strings.isNullOrEmpty(extensionName)) { + extensions.add(extensionName); + } + } + } + + public static LaunchSettings fromConfiguration(ILaunchConfiguration configuration) { + var extension = LaunchHelper.getTestExtension(configuration); + var settings = new LaunchSettings(); + + var filter = new Filter(); + filter.addModule(LaunchConfigurationAttributes.getTestModuleName(configuration)); + if (extension != null) { + filter.addExtension(Projects.getProjectName(extension)); + settings.extensionName = extension.getDtProject().getName(); + } + + var tests = LaunchConfigurationAttributes.getTestMethods(configuration); + if (tests != null && tests.size() == 1) { + var chunks = tests.get(0).split("\\."); //$NON-NLS-1$ + if (chunks.length == 2 && chunks[1].equalsIgnoreCase(TestFinder.REGISTRATION_METHOD_NAME)) { + filter.modules.add(chunks[0]); + tests = Collections.emptyList(); + } + } + filter.tests = tests; + + settings.name = configuration.getName(); + settings.workPath = LaunchHelper.getWorkPath(settings.name).toString(); + settings.reportPath = settings.workPath; + settings.filter = filter; + + return settings; + } +} diff --git a/viewer/src/main/java/ru/biatech/edt/junit/yaxunit/Launcher.java b/viewer/src/main/java/ru/biatech/edt/junit/yaxunit/Launcher.java index b5a395f..c4b996e 100644 --- a/viewer/src/main/java/ru/biatech/edt/junit/yaxunit/Launcher.java +++ b/viewer/src/main/java/ru/biatech/edt/junit/yaxunit/Launcher.java @@ -16,13 +16,9 @@ package ru.biatech.edt.junit.yaxunit; -import com._1c.g5.v8.dt.core.platform.IExtensionProject; import com._1c.g5.v8.dt.launching.core.ILaunchConfigurationAttributes; import com.google.common.base.Strings; -import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubMonitor; @@ -35,101 +31,66 @@ import ru.biatech.edt.junit.launcher.v8.LaunchConfigurationAttributes; import ru.biatech.edt.junit.launcher.v8.LaunchHelper; import ru.biatech.edt.junit.ui.JUnitMessages; -import ru.biatech.edt.junit.v8utils.Projects; -import java.io.File; -import java.io.FileWriter; import java.io.Writer; -import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collections; -import java.util.List; public class Launcher implements IUnitLauncher { private static final String RUN_PARAMETERS = "RunUnitTests="; private static final String PARAMETERS_FILE_NAME = "xUnitParams.json"; - private static final String REPORT_FORMAT = "jUnit"; + public static final String REPORT_FORMAT = "jUnit"; @Override public void launch(ILaunchConfiguration configuration, String launchMode, ILaunch launch, IProgressMonitor monitor) throws CoreException { TestViewerPlugin.log().debug(JUnitMessages.Launcher_Launch, configuration); + var settings = LaunchSettings.fromConfiguration(configuration); + var oneCConfiguration = LaunchHelper.getTargetConfiguration(configuration); - var oneCConfigurationCopy = oneCConfiguration.copy("YAX: " + configuration.getName()); //$NON-NLS-1$ + if (oneCConfiguration == null) { + TestViewerPlugin.log().logError("Не указана конфигурация запуска 1С:Предприятие"); + launch.terminate(); + return; + } + + var oneCConfigurationCopy = oneCConfiguration.copy("YAX. " + configuration.getName()); //$NON-NLS-1$ - configure(oneCConfigurationCopy, configuration); + configure(oneCConfigurationCopy, settings); copyAttributes(configuration, oneCConfigurationCopy); oneCConfigurationCopy.launch(launchMode, SubMonitor.convert(monitor, 1)); } @Override - public void configure(ILaunchConfigurationWorkingCopy oneCConfiguration, ILaunchConfiguration unitConfiguration) { - var workPath = LaunchHelper.getWorkPath(unitConfiguration); - String extensionName = LaunchConfigurationAttributes.getTestExtensionName(unitConfiguration); + public void configure(ILaunchConfigurationWorkingCopy configuration, ILaunchConfiguration basicConfiguration) { + var settings = LaunchSettings.fromConfiguration(basicConfiguration); + configure(configuration, settings); + } + + public void configure(ILaunchConfigurationWorkingCopy oneCConfiguration, LaunchSettings settings) { + var startupParameters = RUN_PARAMETERS + createConfig(settings); - String startupParameters = RUN_PARAMETERS + createConfig(unitConfiguration, workPath); oneCConfiguration.setAttribute(ILaunchConfigurationAttributes.STARTUP_OPTION, startupParameters); - oneCConfiguration.setAttribute(LaunchConfigurationAttributes.WORK_PATH, workPath.toString()); - oneCConfiguration.setAttribute(LaunchConfigurationAttributes.PROJECT, extensionName); + oneCConfiguration.setAttribute(LaunchConfigurationAttributes.WORK_PATH, settings.getWorkPath()); + oneCConfiguration.setAttribute(LaunchConfigurationAttributes.PROJECT, settings.getExtensionName()); oneCConfiguration.setAttribute(LaunchConfigurationAttributes.ATTR_TEST_RUNNER_KIND, TestKindRegistry.YAXUNIT_TEST_KIND_ID); } - protected String createConfig(ILaunchConfiguration configuration, Path workPath) { - File file = new File(workPath.toFile(), PARAMETERS_FILE_NAME); //$NON-NLS-1$ + protected String createConfig(LaunchSettings settings) { + var path = Path.of(settings.getWorkPath(), PARAMETERS_FILE_NAME); - JsonObject config = new JsonObject(); - - setFilter(config, configuration); - - config.addProperty("reportPath", workPath.toString()); //$NON-NLS-1$ - config.addProperty("reportFormat", REPORT_FORMAT); //$NON-NLS-1$ - config.addProperty("closeAfterTests", true); //$NON-NLS-1$ - - try (Writer writer = new FileWriter(file, StandardCharsets.UTF_8)) { - Gson gson = new GsonBuilder().create(); - gson.toJson(config, writer); + try (Writer writer = Files.newBufferedWriter(path)) { + new GsonBuilder() + .excludeFieldsWithoutExposeAnnotation() + .create() + .toJson(settings, writer); } catch (Exception e) { TestViewerPlugin.log().logError(e); } - TestViewerPlugin.log().debug(JUnitMessages.Launcher_ConfigurationLocation, file); - return file.toString(); - } - - protected void setFilter(JsonObject config, ILaunchConfiguration configuration) { - String testModuleName = LaunchConfigurationAttributes.getTestModuleName(configuration); - IExtensionProject extension = LaunchHelper.getTestExtension(configuration); - List tests = LaunchConfigurationAttributes.getTestMethods(configuration); - - if (tests != null && tests.size() == 1) { - String[] chunks = tests.get(0).split("\\."); //$NON-NLS-1$ - if (chunks.length == 2 && chunks[1].equalsIgnoreCase(TestFinder.REGISTRATION_METHOD_NAME)) { - testModuleName = chunks[0]; - tests = Collections.emptyList(); - } - } - JsonObject filter = new JsonObject(); - - if (testModuleName != null && !testModuleName.isBlank()) { - JsonArray array = new JsonArray(); - array.add(testModuleName); - filter.add("modules", array); //$NON-NLS-1$ - } - - if (extension != null) { - JsonArray array = new JsonArray(); - array.add(Projects.getProjectName(extension)); - filter.add("extensions", array); //$NON-NLS-1$ - } - - if (tests != null && !tests.isEmpty()) { - JsonArray array = new JsonArray(); - tests.forEach(array::add); - filter.add("tests", array); //$NON-NLS-1$ - } - - config.add("filter", filter); //$NON-NLS-1$ + TestViewerPlugin.log().debug(JUnitMessages.Launcher_ConfigurationLocation, path); + return path.toString(); } protected void copyAttributes(ILaunchConfiguration unitConfiguration, ILaunchConfigurationWorkingCopy oneCConfiguration) {