eric7/Unittest/Interfaces/UTExecutorBase.py

branch
unittest
changeset 9062
7f27bf3b50c3
parent 9059
e7fd342f8bfc
child 9063
f1d7dd7ae471
equal deleted inserted replaced
9061:22dab1be7953 9062:7f27bf3b50c3
19 19
20 class ResultCategory(IntEnum): 20 class ResultCategory(IntEnum):
21 """ 21 """
22 Class defining the supported result categories. 22 Class defining the supported result categories.
23 """ 23 """
24 RUNNING = 0
24 FAIL = 1 25 FAIL = 1
25 OK = 2 26 OK = 2
26 SKIP = 3 27 SKIP = 3
27 PENDING = 4 28 PENDING = 4
28 29
30 @dataclass 31 @dataclass
31 class UTTestResult: 32 class UTTestResult:
32 """ 33 """
33 Class containing the test result data. 34 Class containing the test result data.
34 """ 35 """
35 category: int # result category 36 category: ResultCategory # result category
36 status: str # test status 37 status: str # test status
37 name: str # test name 38 name: str # test name
38 message: str # short result message 39 id: str # test id
39 extra: str # additional information text 40 description: str = "" # short description of test
40 duration: float # test duration 41 message: str = "" # short result message
41 filename: str # file name of a failed test 42 extra: list = None # additional information text
42 lineno: int # line number of a failed test 43 duration: float = None # test duration
44 filename: str = None # file name of a failed test
45 lineno: int = None # line number of a failed test
43 46
44 47
45 @dataclass 48 @dataclass
46 class UTTestConfig: 49 class UTTestConfig:
47 """ 50 """
59 62
60 class UTExecutorBase(QObject): 63 class UTExecutorBase(QObject):
61 """ 64 """
62 Base class for test framework specific implementations. 65 Base class for test framework specific implementations.
63 66
64 @signal collected(list of str) emitted after all tests have been 67 @signal collected(list of tuple of (str, str, str)) emitted after all tests
65 collected 68 have been collected. Tuple elements are the test id, the test name and
69 a short description of the test.
66 @signal collectError(list of tuple of (str, str)) emitted when errors 70 @signal collectError(list of tuple of (str, str)) emitted when errors
67 are encountered during test collection. Tuple elements are the 71 are encountered during test collection. Tuple elements are the
68 test name and the error message. 72 test name and the error message.
69 @signal startTest(list of str) emitted before tests are run 73 @signal startTest(tuple of (str, str, str) emitted before tests are run.
74 Tuple elements are test id, test name and short description.
70 @signal testResult(UTTestResult) emitted when a test result is ready 75 @signal testResult(UTTestResult) emitted when a test result is ready
71 @signal testFinished(list, str) emitted when the test has finished. 76 @signal testFinished(list, str) emitted when the test has finished.
72 The elements are the list of test results and the captured output 77 The elements are the list of test results and the captured output
73 of the test worker (if any). 78 of the test worker (if any).
79 @signal testRunFinished(int, float) emitted when the test run has finished.
80 The elements are the number of tests run and the duration in seconds
74 @signal stop() emitted when the test process is being stopped. 81 @signal stop() emitted when the test process is being stopped.
82 @signal coverageDataSaved(str) emitted after the coverage data was saved.
83 The element is the absolute path of the coverage data file.
75 """ 84 """
76 collected = pyqtSignal(list) 85 collected = pyqtSignal(list)
77 collectError = pyqtSignal(list) 86 collectError = pyqtSignal(list)
78 startTest = pyqtSignal(list) 87 startTest = pyqtSignal(tuple)
79 testResult = pyqtSignal(UTTestResult) 88 testResult = pyqtSignal(UTTestResult)
80 testFinished = pyqtSignal(list, str) 89 testFinished = pyqtSignal(list, str)
90 testRunFinished = pyqtSignal(int, float)
81 stop = pyqtSignal() 91 stop = pyqtSignal()
92 coverageDataSaved = pyqtSignal(str)
82 93
83 module = "" 94 module = ""
84 name = "" 95 name = ""
85 runner = "" 96 runner = ""
86 97
87 def __init__(self, testWidget, logfile=None): 98 def __init__(self, testWidget):
88 """ 99 """
89 Constructor 100 Constructor
90 101
91 @param testWidget reference to the unit test widget 102 @param testWidget reference to the unit test widget
92 @type UnittestWidget 103 @type UnittestWidget
93 @param logfile file name to log test results to (defaults to None)
94 @type str (optional)
95 """ 104 """
96 super().__init__(testWidget) 105 super().__init__(testWidget)
97 106
98 self.__process = None 107 self.__process = None
99 self._logfile = logfile
100 # TODO: add log file creation
101 108
102 @classmethod 109 @classmethod
103 def isInstalled(cls, interpreter): 110 def isInstalled(cls, interpreter):
104 """ 111 """
105 Class method to check whether a test framework is installed. 112 Class method to check whether a test framework is installed.

eric ide

mercurial