All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.theangrydev.yatspecfluent.YatspecFluentCommands Maven / Gradle / Ivy

Go to download

A plugin for the yatspec acceptance test library used to write acceptance tests in a fluent way, reusing givens, whens and thens.

The newest version!
/*
 * Copyright 2016 Liam Williams .
 *
 * This file is part of yatspec-fluent.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.github.theangrydev.yatspecfluent;

import com.googlecode.yatspec.state.givenwhenthen.WithTestState;
import org.junit.rules.TestRule;

/**
 * These are the BDD methods that are used to write tests.
 *
 * @param  The type of test result produced by the {@link When}
 */
@SuppressWarnings("PMD.TooManyMethods") // This is part of the API design
public interface YatspecFluentCommands extends TestRule, WithTestState, WriteOnlyTestItems {

    /**
     * Prime the given immediately.
     *
     * @param given The first given in the acceptance test, which should be built up inside the brackets
     */
    void given(Given given);

    /**
     * Same as {@link #given(Given)}.
     * 

* Prime the given immediately. * * @param given The first given in the acceptance test, which should be built up inside the brackets */ void and(Given given); /** * Invoke the system under test and store the {@link TestResult} ready for the assertions. * * @param when The system under test, which should be built up inside the brackets * @param The type of {@link When} */ > void when(T when); /** * Adapt the 'when' to a 'given'. This is a common pattern when e.g. calling an endpoint that changes some state in the database. * This is the equivalent of {@link #given(Given)}. * * @param when The 'when' to adapt to a 'given' */ void given(When when); /** * Same as {@link #given(When)}. *

* Adapt the 'when' to a 'given'. This is a common pattern when e.g. calling an endpoint that changes some state in the database. * This is the equivalent of {@link #given(Given)}. * * @param when The 'when' to adapt to a 'given' */ void and(When when); /** * Perform an assertion. Assertions should be chained outside the brackets. * * @param thenAssertion A {@link ThenAssertion} that will produce a {@link Then} given the stored {@link TestResult} * @param The type of fluent assertions that will be performed * @return The fluent assertions instance */ Then then(ThenAssertion thenAssertion); /** * Same as {@link #then(ThenAssertion)}. *

* Perform an assertion. Assertions should be chained outside the brackets. * * @param thenAssertion A {@link ThenAssertion} that will produce a {@link Then} given the stored {@link TestResult} * @param The type of fluent assertions that will be performed * @return The fluent assertions instance */ Then and(ThenAssertion thenAssertion); /** * Same as {@link #then(ThenVerification)}. *

* Perform a verification, which should be built up inside the brackets. * * @param thenVerification A {@link ThenVerification}, which should be built up inside the brackets */ void and(ThenVerification thenVerification); /** * Perform a verification, which should be built up inside the brackets. * * @param thenVerification A {@link ThenVerification}, which should be built up inside the brackets */ void then(ThenVerification thenVerification); @Override default void addToGivens(String key, Object instance) { testState().interestingGivens.add(key, instance); } @Override default void addToCapturedInputsAndOutputs(String key, Object instance) { testState().capturedInputAndOutputs.add(key, instance); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy