### Question:
JUnitFormatter implements EventListener { private void finishReport() { try { this.out = this.builder.build(); rootElement.setAttribute("name", JUnitFormatter.class.getName()); rootElement.setAttribute("failures", String.valueOf(rootElement.getElementsByTagName("failure").getLength())); rootElement.setAttribute("skipped", String.valueOf(rootElement.getElementsByTagName("skipped").getLength())); rootElement.setAttribute("time", sumTimes(rootElement.getElementsByTagName("testcase"))); if (rootElement.getElementsByTagName("testcase").getLength() == 0) { addDummyTestCase(); } TransformerFactory transfac = TransformerFactory.newInstance(); Transformer trans = transfac.newTransformer(); trans.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult result = new StreamResult(out); DOMSource source = new DOMSource(doc); trans.transform(source, result); closeQuietly(out); } catch (TransformerException e) { throw new CucumberException("Error while transforming.", e); } } JUnitFormatter(AppendableBuilder builder); @Override void setEventPublisher(EventPublisher publisher); void process(Statistics stats);  }### Answer:
@Test public void testFinishReport() { JUnitFormatter junit = new JUnitFormatter(new AppendableBuilder("C:/test/junittest.xml")); PluginFactory pf = new PluginFactory(); PerfRuntimeOptions options = new PerfRuntimeOptions(); Plugins plugins = new Plugins(this.getClass().getClassLoader(), pf, options); plugins.addPlugin(junit); plugins.setEventBusOnPlugins(eventBus); eventBus.send(new StatisticsFinished(eventBus.getTime(),eventBus.getTimeMillis(),new Statistics())); assertTrue(deleteFile("C:/test/junittest.xml")); }