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