public void runPickle(Pickle pickle) {
        try {
            StepTypeRegistry stepTypeRegistry = createTypeRegistryForPickle(pickle);
            snippetGenerators = createSnippetGeneratorsForPickle(stepTypeRegistry);

            // Java8 step definitions will be added to the glue here
            buildBackendWorlds();

            glue.prepareGlue(stepTypeRegistry);

            TestCase testCase = createTestCaseForPickle(pickle);
            testCase.run(bus);
        } finally {
            glue.removeScenarioScopedGlue();
            disposeBackendWorlds();
        }
    }
@Test
    void aftersteps_are_executed_after_failed_step() {
        StubStepDefinition stepDefinition = spy(new StubStepDefinition("some step") {

            @Override
            public void execute(Object[] args) {
                super.execute(args);
                throw new RuntimeException();
            }
        });

        Pickle pickleMatchingStepDefinitions = createPickleMatchingStepDefinitions(stepDefinition);

        final HookDefinition afterStepHook = createHook();

        TestRunnerSupplier runnerSupplier = new TestRunnerSupplier(bus, runtimeOptions) {
            @Override
            public void loadGlue(Glue glue, List<URI> gluePaths) {
                glue.addAfterHook(afterStepHook);
                glue.addStepDefinition(stepDefinition);
            }
        };

        runnerSupplier.get().runPickle(pickleMatchingStepDefinitions);

        InOrder inOrder = inOrder(afterStepHook, stepDefinition);
        inOrder.verify(stepDefinition).execute(any(Object[].class));
        inOrder.verify(afterStepHook).execute(any(TestCaseState.class));
    }