Package org.moresbycoffee.mbyhave8

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec


    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

    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

    }

    @Test
    public void specification_with_only_filtered_out_features_should_not_be_executable() {
        final Specification specification = specificationWith(featureWith(successScenario()).tag("Broken"));
        assertFalse(specification.isExecuteable(new Filter("~Broken")));

    }
View Full Code Here

    }

    @Test
    public void feature_with_only_filtered_out_scenarios_should_not_be_executable() {
        final Feature feature = featureWith(successScenario().tag("Broken"));
        assertFalse(feature.isExecutable(new Filter("~Broken")));
    }
View Full Code Here

    public final SpecOutput execute(final Writer writer) {
        return execute(new AnsiWriterReporter(writer));
    }

    public final SpecOutput execute(final Reporter reporter) {
        final Filter filter = new Filter(System.getProperty("mbyhave.tags"));
        return specification.execute(this.getClass(), reporter, eventAnnouncer, filter);
    }
View Full Code Here

    private final Method[] beforeScenarioMethods;
    private final Method[] afterScenarioMethods;


    public MByHave8Hooks toMByHaveHook(final Object object) {
        return new BaseMByHave8Hooks() {

            @Override
            public void startSpecification(final Specification specification) {
                executeHooks(beforeSpecMethods, object, specification);
            }
View Full Code Here

    private CallbackAnnouncer announcer;
    private InOrder inOrder;
    @Before
    public void setUp() {
        announcer = new CallbackAnnouncer();
        announcer.addListener(hooks1);
        announcer.addListener(hooks2);
        inOrder = inOrder(hooks1, hooks2);
    }
View Full Code Here

    public void before_spec_method_should_be_converted_to_hook() throws Throwable {
        HookTestSpec.beforeSpec.set(new AtomicBoolean(false));

        final HookTestSpec hookTestSpec = new HookTestSpec();
        final Method[] beforeSpecMethods = new Method[] { HookTestSpec.class.getDeclaredMethod("beforeSpecification", Specification.class) };
        final MByHave8Hooks hook = new HookAnnotations(beforeSpecMethods, null, null, null, null, null).toMByHaveHook(hookTestSpec);

        hook.startSpecification(mock(Specification.class));

        assertTrue(HookTestSpec.beforeSpec.get().get());

    }
View Full Code Here

    public void after_spec_method_should_be_converted_to_hook() throws Exception {
        HookTestSpec.afterSpec.set(new AtomicBoolean(false));

        final HookTestSpec hookTestSpec = new HookTestSpec();
        final Method[] afterSpecMethods = new Method[] { HookTestSpec.class.getDeclaredMethod("afterSpecification", Specification.class, SpecOutput.class) };
        final MByHave8Hooks hook = new HookAnnotations(null, afterSpecMethods, null, null, null, null).toMByHaveHook(hookTestSpec);

        hook.endSpecification(mock(Specification.class), mock(SpecOutput.class));

        assertTrue(HookTestSpec.afterSpec.get().get());

    }
View Full Code Here

TOP

Related Classes of org.moresbycoffee.mbyhave8.MByHaveSpec

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.