use of com.intellij.execution.TestStateStorage in project intellij-community by JetBrains.
the class ShowRecentTests method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null)
return;
UsageTrigger.trigger(ID);
final TestStateStorage testStorage = TestStateStorage.getInstance(project);
final TestLocator testLocator = new TestLocator(project);
final RecentTestRunnerImpl testRunner = new RecentTestRunnerImpl(project, testLocator);
final Map<String, TestStateStorage.Record> records = testStorage.getRecentTests(TEST_LIMIT, getSinceDate());
RunConfigurationByRecordProvider configurationProvider = new RunConfigurationByRecordProvider(project);
RecentTestsListProvider listProvider = new RecentTestsListProvider(configurationProvider, records);
List<RecentTestsPopupEntry> entries = listProvider.getTestsToShow();
SelectTestStep selectStepTest = new SelectTestStep("Debug Recent Tests", entries, testRunner);
RecentTestsListPopup popup = new RecentTestsListPopup(selectStepTest, testRunner, testLocator);
popup.showCenteredInCurrentWindow(project);
cleanDeadTests(entries, testLocator, testStorage);
}
use of com.intellij.execution.TestStateStorage in project intellij-community by JetBrains.
the class RunLineMarkerTest method testNestedTestClass.
public void testNestedTestClass() throws Exception {
TestStateStorage stateStorage = TestStateStorage.getInstance(getProject());
String testUrl = "java:suite://Main$MainTest";
try {
stateStorage.writeState(testUrl, new TestStateStorage.Record(TestStateInfo.Magnitude.FAILED_INDEX.getValue(), new Date(), 0));
myFixture.addClass("package junit.framework; public class TestCase {}");
PsiFile file = myFixture.configureByText("MainTest.java", "public class Main {\n" + " public class Main<caret>Test extends junit.framework.TestCase {\n" + " public void testFoo() {\n" + " }\n" + " }" + "}");
RunLineMarkerContributor.Info info = new TestRunLineMarkerProvider().getInfo(file.findElementAt(myFixture.getCaretOffset()));
assertNotNull(info);
assertEquals(AllIcons.RunConfigurations.TestState.Red2, info.icon);
} finally {
stateStorage.removeState(testUrl);
}
}
use of com.intellij.execution.TestStateStorage in project flutter-intellij by flutter.
the class FlutterTestLineMarkerContributor method getTestStateIcon.
@NotNull
private static Icon getTestStateIcon(@NotNull PsiElement element, @NotNull Icon defaultIcon) {
// SMTTestProxy maps test run data to a URI derived from a location hint produced by `package:test`.
// If we can find corresponding data, we can provide state-aware icons. If not, we default to
// a standard Run state.
PsiFile containingFile;
try {
containingFile = element.getContainingFile();
} catch (PsiInvalidElementAccessException e) {
containingFile = null;
}
final Project project = element.getProject();
final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
final Document document = containingFile == null ? null : psiDocumentManager.getDocument(containingFile);
if (document != null) {
final int textOffset = element.getTextOffset();
final int lineNumber = document.getLineNumber(textOffset);
// e.g., dart_location:///Users/pq/IdeaProjects/untitled1298891289891/test/unit_test.dart,3,2,["my first unit test"]
final String path = containingFile.getVirtualFile().getPath();
final String testLocationPrefix = "dart_location://" + path + "," + lineNumber;
final TestStateStorage storage = TestStateStorage.getInstance(project);
if (storage != null) {
final Map<String, TestStateStorage.Record> tests = storage.getRecentTests(SCANNED_TEST_RESULT_LIMIT, getSinceDate());
if (tests != null) {
// TODO(pq): investigate performance implications.
for (Map.Entry<String, TestStateStorage.Record> entry : tests.entrySet()) {
if (entry.getKey().startsWith(testLocationPrefix)) {
final TestStateStorage.Record state = entry.getValue();
final TestStateInfo.Magnitude magnitude = TestIconMapper.getMagnitude(state.magnitude);
if (magnitude != null) {
switch(magnitude) {
case IGNORED_INDEX:
return AllIcons.RunConfigurations.TestState.Yellow2;
case ERROR_INDEX:
case FAILED_INDEX:
return AllIcons.RunConfigurations.TestState.Red2;
case PASSED_INDEX:
case COMPLETE_INDEX:
return AllIcons.RunConfigurations.TestState.Green2;
default:
}
}
}
}
}
}
}
return defaultIcon;
}
Aggregations