use of org.robolectric.pluginapi.perf.PerfStatsReporter in project robolectric by robolectric.
the class SandboxTestRunner method reportPerfStats.
private void reportPerfStats(PerfStatsCollector perfStatsCollector) {
if (perfStatsReporters.isEmpty()) {
return;
}
Metadata metadata = perfStatsCollector.getMetadata();
Collection<Metric> metrics = perfStatsCollector.getMetrics();
for (PerfStatsReporter perfStatsReporter : perfStatsReporters) {
try {
perfStatsReporter.report(metadata, metrics);
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of org.robolectric.pluginapi.perf.PerfStatsReporter in project robolectric by robolectric.
the class RobolectricTestRunnerTest method shouldReportPerfStats.
@Test
public void shouldReportPerfStats() throws Exception {
List<Metric> metrics = new ArrayList<>();
PerfStatsReporter reporter = (metadata, metrics1) -> metrics.addAll(metrics1);
RobolectricTestRunner runner = new SingleSdkRobolectricTestRunner(TestWithTwoMethods.class, RobolectricTestRunner.defaultInjector().bind(PerfStatsReporter[].class, new PerfStatsReporter[] { reporter }).build());
runner.run(notifier);
Set<String> metricNames = metrics.stream().map(Metric::getName).collect(toSet());
assertThat(metricNames).contains("initialization");
}
Aggregations