void (@NotNull List<? extends RunnerAndConfigurationSettings> configurations, @NotNull Set<TestUsageDescriptor> expected, boolean withTemporary) { final Project project = getProject(); final RunManager manager = RunManager.getInstance(project); try { for (RunnerAndConfigurationSettings configuration : configurations) { manager.addConfiguration(configuration); } Set<MetricEvent> usages = collectProjectStateCollectorEvents(RunConfigurationTypeUsagesCollector.class, project); assertEquals(expected.size(), usages.size()); assertEquals(expected, toTestUsageDescriptor(usages)); if (withTemporary) { for (RunnerAndConfigurationSettings configuration : configurations) { configuration.setTemporary(true); } final Set<TestUsageDescriptor> temporaryExpected = new HashSet<>(); for (TestUsageDescriptor descriptor : expected) { if (descriptor.myKey.equals("configured.in.project")) { final FeatureUsageData data = descriptor.myData.copy().addData("temporary", true); temporaryExpected.add(new TestUsageDescriptor(descriptor.myKey, data)); } } temporaryExpected.add(createTotalCountUsageDescriptor( configurations.size(), (int)configurations.stream().filter(settings -> settings.isTemporary()).count())); Set<MetricEvent> temporaryUsages = collectProjectStateCollectorEvents(RunConfigurationTypeUsagesCollector.class, project); assertEquals(temporaryExpected.size(), temporaryUsages.size()); final Set<TestUsageDescriptor> actual = toTestUsageDescriptor(temporaryUsages); assertEquals(temporaryExpected, actual); } } finally { for (RunnerAndConfigurationSettings configuration : configurations) { manager.removeConfiguration(configuration); } RunManagerConfig config = new RunManagerConfig(PropertiesComponent.getInstance()); config.setRecentsLimit(RunManagerConfig.DEFAULT_RECENT_LIMIT); } }