StacktraceBuilder extends RobotDefaultAgentEventListener { @Override public void handleClosed() { stacktrace.destroy(); } StacktraceBuilder(final Stacktrace stacktrace, final ElementsLocator locator,
            final RobotBreakpointSupplier breakpointSupplier); @Override void handleSuiteStarted(final SuiteStartedEvent event); @Override void handleTestStarted(final TestStartedEvent event); @Override void handleKeywordAboutToStart(final KeywordStartedEvent event); @Override void handleKeywordStarted(final KeywordStartedEvent event); @Override void handleKeywordAboutToEnd(final KeywordEndedEvent event); @Override void handleKeywordEnded(final KeywordEndedEvent event); @Override void handleTestEnded(final TestEndedEvent event); @Override void handleSuiteEnded(final SuiteEndedEvent event); @Override void handleResourceImport(final ResourceImportEvent event); @Override void handleVariables(final VariablesEvent event); @Override void handleClosed();  }
@Test public void stackIsDestroyed_whenExecutionEnds() { final Stacktrace stack = new Stacktrace(); stack.push(new StackFrame("Suite", FrameCategory.SUITE, 0, mock(StackFrameContext.class))); stack.push(new StackFrame("Test", FrameCategory.TEST, 1, mock(StackFrameContext.class))); final StacktraceBuilder builder = new StacktraceBuilder(stack, mock(ElementsLocator.class), new RobotBreakpointSupplier()); assertThat(stack.size()).isEqualTo(2); builder.handleClosed(); assertThat(stack.size()).isEqualTo(0); }