001/*
002 * Licensed to the author under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package de.cuioss.test.generator.internal.net.java.quickcheck;
018
019/**
020 * <p>
021 * A characteristic specifies an aspect of a system under test.
022 * </p>
023 * <p>
024 * The characteristic stated is tested with a number of test data instances
025 * generated by a generator. All runs of a characteristic's
026 * {@link Characteristic#specify(Object)} method have to be valid. Invalid runs
027 * have to throw an exception.
028 * </p>
029 *
030 * @param <T> type of generated random test instances
031 *
032 */
033@SuppressWarnings("ProhibitedExceptionDeclared")
034public interface Characteristic<T> {
035
036    /**
037     * Checks the characteristic's specification for a test case instance.
038     *
039     * @param instance for which to check the characteristic
040     * @throws Throwable if the instance does not confirm to the characteristic's
041     *                   specification
042     */
043    void specify(T instance) throws Throwable;
044
045    /**
046     * Set up operation before {@link Characteristic#specify(Object)} is executed.
047     */
048    void setUp() throws Exception;
049
050    /**
051     * Clean up operation after {@link Characteristic#specify(Object)} was executed.
052     */
053    void tearDown() throws Exception;
054
055    /**
056     * Unique name for this characteristic instance.
057     *
058     * @return name of the characteristic.
059     */
060    String name();
061}