File indexing completed on 2024-04-28 04:36:31
0001 /* 0002 SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_ITESTSUITE_H 0008 #define KDEVPLATFORM_ITESTSUITE_H 0009 0010 #include "interfacesexport.h" 0011 0012 #include <QMetaType> 0013 0014 class KJob; 0015 class QString; 0016 class QStringList; 0017 0018 namespace KDevelop { 0019 0020 class IndexedDeclaration; 0021 class IProject; 0022 0023 /** 0024 * A unit test suite class. 0025 **/ 0026 class KDEVPLATFORMINTERFACES_EXPORT ITestSuite 0027 { 0028 0029 public: 0030 0031 /** 0032 * Specifies how much output a test job should produce 0033 **/ 0034 enum TestJobVerbosity 0035 { 0036 Silent, ///< No tool view is raised by the job 0037 Verbose ///< The job raises an output tool view 0038 }; 0039 0040 /** 0041 * Destructor 0042 **/ 0043 virtual ~ITestSuite(); 0044 0045 /** 0046 * @returns the display name of this suite. It has to be unique within a project. 0047 **/ 0048 virtual QString name() const = 0; 0049 /** 0050 * @returns the list of all test cases in this suite. 0051 **/ 0052 virtual QStringList cases() const = 0; 0053 /** 0054 * Get the project to which this test suite belongs. 0055 * Since all suites must have a project associated, 0056 * this function should never return 0. 0057 * 0058 * @returns the test suite's project. 0059 **/ 0060 virtual IProject* project() const = 0; 0061 0062 /** 0063 * Return a job that will execute all the test cases in this suite. 0064 * 0065 * The implementation of this class is responsible for creating the job 0066 * and interpreting its results. After the job is finished, the test results 0067 * should be made available to the result() function. 0068 * 0069 * Starting the job is up to the caller, usually by registering it with 0070 * the run controller. 0071 **/ 0072 virtual KJob* launchAllCases(TestJobVerbosity verbosity) = 0; 0073 0074 /** 0075 * @param testCases list of test cases to run 0076 * @returns a KJob that will run the specified @p testCases. 0077 * @sa launchAllCases() 0078 **/ 0079 virtual KJob* launchCases(const QStringList& testCases, TestJobVerbosity verbosity) = 0; 0080 0081 /** 0082 * @param testCase the test case to run 0083 * @returns a KJob that will run only @p testCase. 0084 * @sa launchAllCases() 0085 **/ 0086 virtual KJob* launchCase(const QString& testCase, TestJobVerbosity verbosity) = 0; 0087 0088 /** 0089 * The location in source code where the test suite is declared. 0090 * If no such declaration can be found, an invalid declaration is returned. 0091 **/ 0092 virtual IndexedDeclaration declaration() const = 0; 0093 0094 /** 0095 * The location in source code where the test case @p testCase is declared. 0096 * If no such declaration can be found, an invalid declaration is returned. 0097 * 0098 * This function may also return declarations for setup and teardown functions, 0099 * even though these functions are not included in cases(). 0100 * 0101 * @param testCase the test case 0102 **/ 0103 virtual IndexedDeclaration caseDeclaration(const QString& testCase) const = 0; 0104 }; 0105 0106 } 0107 0108 Q_DECLARE_METATYPE(KDevelop::ITestSuite*) 0109 0110 #endif // KDEVPLATFORM_ITESTSUITE_H