Package org.moresbycoffee.mbyhave8.annotations

Examples of org.moresbycoffee.mbyhave8.annotations.HookAnnotations


    public void before_scenario_method_should_be_converted_to_hook() throws Exception {
        HookTestSpec.beforeScenario.set(new AtomicBoolean(false));

        final HookTestSpec hookTestSpec = new HookTestSpec();
        final Method[] beforeScenarioMethods = new Method[] { HookTestSpec.class.getDeclaredMethod("beforeScenario", Scenario.class) };
        final MByHave8Hooks hook = new HookAnnotations(null, null, null, null, beforeScenarioMethods, null).toMByHaveHook(hookTestSpec);

        hook.startScenario("TEST_FEATURE_ID", mock(Scenario.class));

        assertTrue(HookTestSpec.beforeScenario.get().get());
View Full Code Here


    public void after_scenario_method_should_be_converted_to_hook() throws Exception {
        HookTestSpec.afterScenario.set(new AtomicBoolean(false));

        final HookTestSpec hookTestSpec = new HookTestSpec();
        final Method[] afterScenarioMethods = new Method[] { HookTestSpec.class.getDeclaredMethod("afterScenario", Scenario.class, ScenarioResult.class) };
        final MByHave8Hooks hook = new HookAnnotations(null, null, null, null, null, afterScenarioMethods).toMByHaveHook(hookTestSpec);

        hook.endScenario("TEST_FEATURE_ID", mock(Scenario.class), ScenarioResult.Success);

        assertTrue(HookTestSpec.afterScenario.get().get());
View Full Code Here

    @Test(expected = LifeCycleHookException.class)
    public void should_throw_exception_if_error_happens_in_hook_execution() throws Exception {

        final Method[] beforeScenarioMethods = new Method[] { HookExceptionTestSpec.class.getDeclaredMethod("beforeScenario") };
        final MByHave8Hooks hook = new HookAnnotations(null, null, null, null, beforeScenarioMethods, null).toMByHaveHook(new HookExceptionTestSpec());

        hook.startScenario("TEST_FEATURE_ID", mock(Scenario.class));
    }
View Full Code Here

    }

    @Test
    public void should_add_before_specification_method_to_before_spec_hook() {
        final HookAnnotations annotations = AnnotationHookProcess.processClass(TestClass.class);
        final Method[] beforeSpecMethods = annotations.getBeforeSpecMethods();
        assertEquals("beforeSpecificationMethod", beforeSpecMethods[0].getName());
    }
View Full Code Here

        assertEquals("beforeSpecificationMethod", beforeSpecMethods[0].getName());
    }

    @Test
    public void should_add_after_specification_method_to_after_spec_hook() {
        final HookAnnotations annotations = AnnotationHookProcess.processClass(TestClass.class);
        final Method[] afterSpecMethods = annotations.getAfterSpecMethods();
        assertEquals("afterSpecificationMethod", afterSpecMethods[0].getName());
    }
View Full Code Here

        assertEquals("afterSpecificationMethod", afterSpecMethods[0].getName());
    }

    @Test
    public void should_add_before_feature_method_to_before_feature_hook() {
        final HookAnnotations annotations = AnnotationHookProcess.processClass(TestClass.class);
        final Method[] beforeFeatureMethods = annotations.getBeforeFeatureMethods();
        assertEquals("beforeFeatureMethod", beforeFeatureMethods[0].getName());
    }
View Full Code Here

        assertEquals("beforeFeatureMethod", beforeFeatureMethods[0].getName());
    }

    @Test
    public void should_add_after_feature_method_to_after_feature_hook() {
        final HookAnnotations annotations = AnnotationHookProcess.processClass(TestClass.class);
        final Method[] afterFeatureMethods = annotations.getAfterFeatureMethods();
        assertEquals("afterFeatureMethod", afterFeatureMethods[0].getName());
    }
View Full Code Here

        assertEquals("afterFeatureMethod", afterFeatureMethods[0].getName());
    }

    @Test
    public void should_add_before_scenario_method_to_before_scenario_hook() {
        final HookAnnotations annotations = AnnotationHookProcess.processClass(TestClass.class);
        final Method[] beforeScenarioMethods = annotations.getBeforeScenarioMethods();
        assertEquals("beforeScenarioMethod", beforeScenarioMethods[0].getName());
    }
View Full Code Here

        assertEquals("beforeScenarioMethod", beforeScenarioMethods[0].getName());
    }

    @Test
    public void should_add_after_scenario_method_to_after_scenario_hook() {
        final HookAnnotations annotations = AnnotationHookProcess.processClass(TestClass.class);
        final Method[] afterScenarioMethods = annotations.getAfterScenarioMethods();
        assertEquals("afterScenarioMethod", afterScenarioMethods[0].getName());
    }
View Full Code Here

    private static void executeHooks(final Method[] methods, final Object object, final Object... parameters) {
        for (final Method method : methods) {
            try {
                ReflectionUtils.invokeWithOptionalParameter(method, object, parameters);
            } catch (IllegalAccessException | IllegalArgumentException e) {
                throw new LifeCycleHookException("The '" + method.toString() + "' hook method can not be invoked on instance: " + object, e);
            } catch (final InvocationTargetException e) {
                throw new LifeCycleHookException("Exception occured during execution of " + method.toString(), e.getCause());
            }
        }

    }
View Full Code Here

TOP

Related Classes of org.moresbycoffee.mbyhave8.annotations.HookAnnotations

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.