File: itestcontroller.h

package info (click to toggle)
kdevelop 4%3A22.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 70,096 kB
  • sloc: cpp: 284,635; javascript: 3,558; python: 3,422; sh: 1,319; ansic: 685; xml: 331; php: 95; lisp: 66; makefile: 39; sed: 12
file content (128 lines) | stat: -rw-r--r-- 3,571 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
    SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#ifndef KDEVPLATFORM_ITESTCONTROLLER_H
#define KDEVPLATFORM_ITESTCONTROLLER_H

#include "interfacesexport.h"

#include <QList>
#include <QObject>
#include <QHash>
#include <QString>

class QStringList;

namespace KDevelop {

struct TestResult;

class IProject;
class ITestSuite;


/**
 * The result of a single unit test run
 **/
struct KDEVPLATFORMINTERFACES_EXPORT TestResult
{
    /**
     * Enumeration of possible test case results
     **/
    enum TestCaseResult
    {
        NotRun, ///< The test case was not selected for running.
        Skipped, ///< The test case was skipped.
        Passed, ///< The test case was run and passed.
        Failed, ///< The test case was run and failed.
        ExpectedFail, ///< The test case was expected to fail, and did.
        UnexpectedPass, ///< The test case was expected to fail, but passed.
        Error, ///< There was an error while trying to run the test case.
    };

    /**
     * The individual results of all test cases.
     **/
    QHash<QString, TestCaseResult> testCaseResults;

    /**
     * The total result of the entire suite.
     *
     * This is usually the worst outcome of the individual test cases,
     * but can be different especially when dealing with errors.
     */
    TestCaseResult suiteResult;
};

class KDEVPLATFORMINTERFACES_EXPORT ITestController : public QObject
{
    Q_OBJECT
public:
    explicit ITestController(QObject* parent = nullptr);
    ~ITestController() override;

    /**
     * Add a new test suite.
     *
     * No ownership is taken, the caller stays responsible for the suite.
     *
     * If a suite with the same project and same name exists, the old one will be removed and deleted.
     */
    virtual void addTestSuite(ITestSuite* suite) = 0;
    /**
     * Remove a test suite from the controller.
     *
     * This does not delete the test suite.
     */
    virtual void removeTestSuite(ITestSuite* suite) = 0;

    /**
     * Returns the list of all known test suites.
     */
    virtual QList<ITestSuite*> testSuites() const = 0;
    /**
     * Find a test suite in @p project with @p name.
     */
    virtual ITestSuite* findTestSuite(IProject* project, const QString& name) const = 0;
    /**
     * Return the list of all test suites in @p project.
     */
    virtual QList<ITestSuite*> testSuitesForProject(IProject* project) const = 0;

    /**
     * Notify the controller that a test run for @p suite was finished with result @p result
     */
    virtual void notifyTestRunFinished(ITestSuite* suite, const KDevelop::TestResult& result) = 0;

    /**
     * Notify the controller that a test run for @p suite was started
     */
    virtual void notifyTestRunStarted(KDevelop::ITestSuite* suite, const QStringList& test_cases) = 0;

Q_SIGNALS:
    /**
     * Emitted whenever a new test suite gets added.
     */
    void testSuiteAdded(KDevelop::ITestSuite* suite);
    /**
     * Emitted whenever a test suite gets removed.
     */
    void testSuiteRemoved(KDevelop::ITestSuite* suite);
    /**
     * Emitted after a test suite was run.
     */
    void testRunFinished(KDevelop::ITestSuite* suite, const KDevelop::TestResult& result);
     /**
     * Emitted when a test suite starts.
     */
    void testRunStarted(KDevelop::ITestSuite* suite, const QStringList& test_cases);
};

}

Q_DECLARE_INTERFACE( KDevelop::ITestController, "org.kdevelop.ITestController")

#endif // KDEVPLATFORM_ITESTCONTROLLER_H