@memberjunction/testing-engine 0.0.1 → 2.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -29
- package/dist/drivers/AgentEvalDriver.d.ts +197 -0
- package/dist/drivers/AgentEvalDriver.d.ts.map +1 -0
- package/dist/drivers/AgentEvalDriver.js +370 -0
- package/dist/drivers/AgentEvalDriver.js.map +1 -0
- package/dist/drivers/BaseTestDriver.d.ts +145 -0
- package/dist/drivers/BaseTestDriver.d.ts.map +1 -0
- package/dist/drivers/BaseTestDriver.js +266 -0
- package/dist/drivers/BaseTestDriver.js.map +1 -0
- package/dist/drivers/index.d.ts +6 -0
- package/dist/drivers/index.d.ts.map +1 -0
- package/dist/drivers/index.js +22 -0
- package/dist/drivers/index.js.map +1 -0
- package/dist/engine/TestEngine.d.ts +148 -0
- package/dist/engine/TestEngine.d.ts.map +1 -0
- package/dist/engine/TestEngine.js +490 -0
- package/dist/engine/TestEngine.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/oracles/ExactMatchOracle.d.ts +98 -0
- package/dist/oracles/ExactMatchOracle.d.ts.map +1 -0
- package/dist/oracles/ExactMatchOracle.js +355 -0
- package/dist/oracles/ExactMatchOracle.js.map +1 -0
- package/dist/oracles/IOracle.d.ts +47 -0
- package/dist/oracles/IOracle.d.ts.map +1 -0
- package/dist/oracles/IOracle.js +7 -0
- package/dist/oracles/IOracle.js.map +1 -0
- package/dist/oracles/LLMJudgeOracle.d.ts +65 -0
- package/dist/oracles/LLMJudgeOracle.d.ts.map +1 -0
- package/dist/oracles/LLMJudgeOracle.js +214 -0
- package/dist/oracles/LLMJudgeOracle.js.map +1 -0
- package/dist/oracles/SQLValidatorOracle.d.ts +78 -0
- package/dist/oracles/SQLValidatorOracle.d.ts.map +1 -0
- package/dist/oracles/SQLValidatorOracle.js +215 -0
- package/dist/oracles/SQLValidatorOracle.js.map +1 -0
- package/dist/oracles/SchemaValidatorOracle.d.ts +61 -0
- package/dist/oracles/SchemaValidatorOracle.d.ts.map +1 -0
- package/dist/oracles/SchemaValidatorOracle.js +193 -0
- package/dist/oracles/SchemaValidatorOracle.js.map +1 -0
- package/dist/oracles/TraceValidatorOracle.d.ts +41 -0
- package/dist/oracles/TraceValidatorOracle.d.ts.map +1 -0
- package/dist/oracles/TraceValidatorOracle.js +159 -0
- package/dist/oracles/TraceValidatorOracle.js.map +1 -0
- package/dist/oracles/index.d.ts +10 -0
- package/dist/oracles/index.d.ts.map +1 -0
- package/dist/oracles/index.js +26 -0
- package/dist/oracles/index.js.map +1 -0
- package/dist/types.d.ts +428 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/cost-calculator.d.ts +92 -0
- package/dist/utils/cost-calculator.d.ts.map +1 -0
- package/dist/utils/cost-calculator.js +137 -0
- package/dist/utils/cost-calculator.js.map +1 -0
- package/dist/utils/result-formatter.d.ts +98 -0
- package/dist/utils/result-formatter.d.ts.map +1 -0
- package/dist/utils/result-formatter.js +252 -0
- package/dist/utils/result-formatter.js.map +1 -0
- package/dist/utils/scoring.d.ts +64 -0
- package/dist/utils/scoring.d.ts.map +1 -0
- package/dist/utils/scoring.js +140 -0
- package/dist/utils/scoring.js.map +1 -0
- package/package.json +36 -7
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Base class for all test driver implementations
|
|
4
|
+
* @module @memberjunction/testing-engine
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.BaseTestDriver = void 0;
|
|
8
|
+
const core_1 = require("@memberjunction/core");
|
|
9
|
+
/**
|
|
10
|
+
* Abstract base class for test driver implementations.
|
|
11
|
+
*
|
|
12
|
+
* Each TestType in the database has a corresponding DriverClass that extends this base.
|
|
13
|
+
* The driver is responsible for:
|
|
14
|
+
* - Parsing test-specific configuration from Configuration JSON
|
|
15
|
+
* - Executing the test with appropriate logic
|
|
16
|
+
* - Running oracles to evaluate results
|
|
17
|
+
* - Calculating scores and determining pass/fail status
|
|
18
|
+
* - Returning structured results
|
|
19
|
+
*
|
|
20
|
+
* BaseTestDriver handles common functionality:
|
|
21
|
+
* - Configuration parsing
|
|
22
|
+
* - Score calculation
|
|
23
|
+
* - Status determination
|
|
24
|
+
* - Logging
|
|
25
|
+
* - Error handling
|
|
26
|
+
*
|
|
27
|
+
* Follows pattern from BaseScheduledJob and BaseAgent.
|
|
28
|
+
*
|
|
29
|
+
* @abstract
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* @RegisterClass(BaseTestDriver, 'AgentEvalDriver')
|
|
33
|
+
* export class AgentEvalDriver extends BaseTestDriver {
|
|
34
|
+
* async Execute(context: DriverExecutionContext): Promise<DriverExecutionResult> {
|
|
35
|
+
* const config = this.parseConfig<AgentEvalConfig>(context.test);
|
|
36
|
+
* // Execute test logic
|
|
37
|
+
* return result;
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
class BaseTestDriver {
|
|
43
|
+
constructor() {
|
|
44
|
+
this._metadata = new core_1.Metadata();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Validate test configuration.
|
|
48
|
+
*
|
|
49
|
+
* Called when creating or updating a test to ensure the configuration is valid
|
|
50
|
+
* for this test type. Override to add type-specific validation.
|
|
51
|
+
*
|
|
52
|
+
* @param test - The test being validated
|
|
53
|
+
* @returns Validation result with errors and warnings
|
|
54
|
+
*/
|
|
55
|
+
async Validate(test) {
|
|
56
|
+
const errors = [];
|
|
57
|
+
const warnings = [];
|
|
58
|
+
// Basic validation that all drivers need
|
|
59
|
+
if (!test.InputDefinition || test.InputDefinition.trim() === '') {
|
|
60
|
+
errors.push({
|
|
61
|
+
category: 'input',
|
|
62
|
+
message: 'InputDefinition is required',
|
|
63
|
+
field: 'InputDefinition',
|
|
64
|
+
suggestion: 'Provide test input definition in JSON format'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// Validate JSON
|
|
69
|
+
try {
|
|
70
|
+
JSON.parse(test.InputDefinition);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
errors.push({
|
|
74
|
+
category: 'input',
|
|
75
|
+
message: `InputDefinition is not valid JSON: ${error.message}`,
|
|
76
|
+
field: 'InputDefinition',
|
|
77
|
+
suggestion: 'Fix JSON syntax errors'
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!test.ExpectedOutcomes || test.ExpectedOutcomes.trim() === '') {
|
|
82
|
+
warnings.push({
|
|
83
|
+
category: 'best-practice',
|
|
84
|
+
message: 'ExpectedOutcomes is recommended for validation',
|
|
85
|
+
recommendation: 'Define expected outcomes to enable automated validation'
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Validate JSON
|
|
90
|
+
try {
|
|
91
|
+
JSON.parse(test.ExpectedOutcomes);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
errors.push({
|
|
95
|
+
category: 'expected-outcome',
|
|
96
|
+
message: `ExpectedOutcomes is not valid JSON: ${error.message}`,
|
|
97
|
+
field: 'ExpectedOutcomes',
|
|
98
|
+
suggestion: 'Fix JSON syntax errors'
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!test.Configuration || test.Configuration.trim() === '') {
|
|
103
|
+
warnings.push({
|
|
104
|
+
category: 'best-practice',
|
|
105
|
+
message: 'Configuration is recommended',
|
|
106
|
+
recommendation: 'Define test configuration including oracles and weights'
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// Validate JSON
|
|
111
|
+
try {
|
|
112
|
+
JSON.parse(test.Configuration);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
errors.push({
|
|
116
|
+
category: 'configuration',
|
|
117
|
+
message: `Configuration is not valid JSON: ${error.message}`,
|
|
118
|
+
field: 'Configuration',
|
|
119
|
+
suggestion: 'Fix JSON syntax errors'
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
valid: errors.length === 0,
|
|
125
|
+
errors,
|
|
126
|
+
warnings
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Calculate overall score from oracle results.
|
|
131
|
+
*
|
|
132
|
+
* If weights are provided, calculates weighted average.
|
|
133
|
+
* Otherwise, calculates simple average.
|
|
134
|
+
*
|
|
135
|
+
* @param oracleResults - Results from oracle evaluations
|
|
136
|
+
* @param weights - Optional scoring weights by oracle type
|
|
137
|
+
* @returns Overall score from 0.0 to 1.0
|
|
138
|
+
* @protected
|
|
139
|
+
*/
|
|
140
|
+
calculateScore(oracleResults, weights) {
|
|
141
|
+
if (oracleResults.length === 0) {
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
if (!weights) {
|
|
145
|
+
// Simple average
|
|
146
|
+
const sum = oracleResults.reduce((acc, r) => acc + r.score, 0);
|
|
147
|
+
return sum / oracleResults.length;
|
|
148
|
+
}
|
|
149
|
+
// Weighted average
|
|
150
|
+
let weightedSum = 0;
|
|
151
|
+
let totalWeight = 0;
|
|
152
|
+
for (const result of oracleResults) {
|
|
153
|
+
const weight = weights[result.oracleType] || 0;
|
|
154
|
+
weightedSum += result.score * weight;
|
|
155
|
+
totalWeight += weight;
|
|
156
|
+
}
|
|
157
|
+
return totalWeight > 0 ? weightedSum / totalWeight : 0;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Determine overall test status from oracle results.
|
|
161
|
+
*
|
|
162
|
+
* Test passes only if ALL oracles pass.
|
|
163
|
+
*
|
|
164
|
+
* @param oracleResults - Results from oracle evaluations
|
|
165
|
+
* @returns 'Passed' if all oracles passed, 'Failed' otherwise
|
|
166
|
+
* @protected
|
|
167
|
+
*/
|
|
168
|
+
determineStatus(oracleResults) {
|
|
169
|
+
if (oracleResults.length === 0) {
|
|
170
|
+
return 'Failed';
|
|
171
|
+
}
|
|
172
|
+
return oracleResults.every(r => r.passed) ? 'Passed' : 'Failed';
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Parse and validate Configuration JSON.
|
|
176
|
+
*
|
|
177
|
+
* Helper method for drivers to parse their configuration with type safety.
|
|
178
|
+
* Throws if configuration is invalid.
|
|
179
|
+
*
|
|
180
|
+
* @template T - The configuration type
|
|
181
|
+
* @param test - The test containing the configuration
|
|
182
|
+
* @returns Parsed configuration
|
|
183
|
+
* @throws Error if configuration is missing or invalid
|
|
184
|
+
* @protected
|
|
185
|
+
*/
|
|
186
|
+
parseConfig(test) {
|
|
187
|
+
if (!test.Configuration) {
|
|
188
|
+
throw new Error('Configuration is required for test execution');
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
return JSON.parse(test.Configuration);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
195
|
+
throw new Error(`Invalid Configuration JSON: ${errorMessage}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Parse and validate InputDefinition JSON.
|
|
200
|
+
*
|
|
201
|
+
* @template T - The input definition type
|
|
202
|
+
* @param test - The test containing the input definition
|
|
203
|
+
* @returns Parsed input definition
|
|
204
|
+
* @throws Error if input definition is missing or invalid
|
|
205
|
+
* @protected
|
|
206
|
+
*/
|
|
207
|
+
parseInputDefinition(test) {
|
|
208
|
+
if (!test.InputDefinition) {
|
|
209
|
+
throw new Error('InputDefinition is required for test execution');
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
return JSON.parse(test.InputDefinition);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
216
|
+
throw new Error(`Invalid InputDefinition JSON: ${errorMessage}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Parse and validate ExpectedOutcomes JSON.
|
|
221
|
+
*
|
|
222
|
+
* @template T - The expected outcomes type
|
|
223
|
+
* @param test - The test containing the expected outcomes
|
|
224
|
+
* @returns Parsed expected outcomes
|
|
225
|
+
* @throws Error if expected outcomes is missing or invalid
|
|
226
|
+
* @protected
|
|
227
|
+
*/
|
|
228
|
+
parseExpectedOutcomes(test) {
|
|
229
|
+
if (!test.ExpectedOutcomes) {
|
|
230
|
+
throw new Error('ExpectedOutcomes is required for test execution');
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
return JSON.parse(test.ExpectedOutcomes);
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
237
|
+
throw new Error(`Invalid ExpectedOutcomes JSON: ${errorMessage}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Log execution progress.
|
|
242
|
+
*
|
|
243
|
+
* @param message - Log message
|
|
244
|
+
* @param verboseOnly - Whether to only log in verbose mode (default: false)
|
|
245
|
+
* @protected
|
|
246
|
+
*/
|
|
247
|
+
log(message, verboseOnly = false) {
|
|
248
|
+
(0, core_1.LogStatusEx)({
|
|
249
|
+
message: `[${this.constructor.name}] ${message}`,
|
|
250
|
+
verboseOnly,
|
|
251
|
+
isVerboseEnabled: () => (0, core_1.IsVerboseLoggingEnabled)()
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Log errors.
|
|
256
|
+
*
|
|
257
|
+
* @param message - Error message
|
|
258
|
+
* @param error - Optional error object
|
|
259
|
+
* @protected
|
|
260
|
+
*/
|
|
261
|
+
logError(message, error) {
|
|
262
|
+
(0, core_1.LogError)(`[${this.constructor.name}] ${message}`, undefined, error);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
exports.BaseTestDriver = BaseTestDriver;
|
|
266
|
+
//# sourceMappingURL=BaseTestDriver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseTestDriver.js","sourceRoot":"","sources":["../../src/drivers/BaseTestDriver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAM8B;AAe9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAsB,cAAc;IAApC;QACc,cAAS,GAAa,IAAI,eAAQ,EAAE,CAAC;IA8PnD,CAAC;IAvOG;;;;;;;;OAQG;IACI,KAAK,CAAC,QAAQ,CAAC,IAAgB;QAClC,MAAM,MAAM,GAAsB,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAwB,EAAE,CAAC;QAEzC,yCAAyC;QACzC,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9D,MAAM,CAAC,IAAI,CAAC;gBACR,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,6BAA6B;gBACtC,KAAK,EAAE,iBAAiB;gBACxB,UAAU,EAAE,8CAA8C;aAC7D,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACJ,gBAAgB;YAChB,IAAI,CAAC;gBACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACrC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC;oBACR,QAAQ,EAAE,OAAO;oBACjB,OAAO,EAAE,sCAAsC,KAAK,CAAC,OAAO,EAAE;oBAC9D,KAAK,EAAE,iBAAiB;oBACxB,UAAU,EAAE,wBAAwB;iBACvC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;Q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C,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,kCAAkC,YAAY,EAAE,CAAC,CAAC;QACtE,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACO,GAAG,CAAC,OAAe,EAAE,cAAuB,KAAK;QACvD,IAAA,kBAAW,EAAC;YACR,OAAO,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE;YAChD,WAAW;YACX,gBAAgB,EAAE,GAAG,EAAE,CAAC,IAAA,8BAAuB,GAAE;SACpD,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACO,QAAQ,CAAC,OAAe,EAAE,KAAa;QAC7C,IAAA,eAAQ,EAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC;CACJ;AA/PD,wCA+PC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drivers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test driver implementations
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./BaseTestDriver"), exports);
|
|
21
|
+
__exportStar(require("./AgentEvalDriver"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/drivers/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,mDAAiC;AACjC,oDAAkC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main testing engine orchestrator
|
|
3
|
+
* @module @memberjunction/testing-engine
|
|
4
|
+
*/
|
|
5
|
+
import { UserInfo } from '@memberjunction/core';
|
|
6
|
+
import { TestEngineBase } from '@memberjunction/testing-engine-base';
|
|
7
|
+
import { IOracle } from '../oracles/IOracle';
|
|
8
|
+
import { TestRunOptions, TestRunResult, TestSuiteRunResult } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Main testing engine that orchestrates test execution.
|
|
11
|
+
*
|
|
12
|
+
* Extends TestEngineBase (UI-safe metadata cache) with execution capabilities.
|
|
13
|
+
* Follows singleton pattern like SchedulingEngine.
|
|
14
|
+
*
|
|
15
|
+
* Responsibilities:
|
|
16
|
+
* - Load and instantiate test drivers via ClassFactory
|
|
17
|
+
* - Manage oracle registry
|
|
18
|
+
* - Execute individual tests and test suites
|
|
19
|
+
* - Create and update TestRun entities
|
|
20
|
+
* - Track execution timing and costs
|
|
21
|
+
* - Handle errors and logging
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const engine = TestEngine.Instance;
|
|
26
|
+
* await engine.Config(false, contextUser);
|
|
27
|
+
*
|
|
28
|
+
* const result = await engine.RunTest('test-id', { verbose: true }, contextUser);
|
|
29
|
+
* console.log(`Test ${result.status}: Score ${result.score}`);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class TestEngine extends TestEngineBase {
|
|
33
|
+
private _driverCache;
|
|
34
|
+
private _oracleRegistry;
|
|
35
|
+
/**
|
|
36
|
+
* Get singleton instance
|
|
37
|
+
*/
|
|
38
|
+
static get Instance(): TestEngine;
|
|
39
|
+
/**
|
|
40
|
+
* Private constructor for singleton
|
|
41
|
+
*/
|
|
42
|
+
private constructor();
|
|
43
|
+
protected AdditionalLoading(contextUser?: UserInfo): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Run a single test.
|
|
46
|
+
*
|
|
47
|
+
* @param testId - ID of the test to run
|
|
48
|
+
* @param options - Test execution options
|
|
49
|
+
* @param contextUser - User context
|
|
50
|
+
* @param suiteRunId - Optional suite run ID if part of a suite
|
|
51
|
+
* @returns Test run result (or array of results if RepeatCount > 1)
|
|
52
|
+
*/
|
|
53
|
+
RunTest(testId: string, options: TestRunOptions, contextUser: UserInfo, suiteRunId?: string | null, suiteTestSequence?: number | null): Promise<TestRunResult | TestRunResult[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Run a test suite.
|
|
56
|
+
*
|
|
57
|
+
* @param suiteId - ID of the test suite to run
|
|
58
|
+
* @param options - Test execution options
|
|
59
|
+
* @param contextUser - User context
|
|
60
|
+
* @returns Test suite run result
|
|
61
|
+
*/
|
|
62
|
+
RunSuite(suiteId: string, options: TestRunOptions, contextUser: UserInfo): Promise<TestSuiteRunResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Register a custom oracle.
|
|
65
|
+
*
|
|
66
|
+
* @param oracle - Oracle implementation
|
|
67
|
+
*/
|
|
68
|
+
RegisterOracle(oracle: IOracle): void;
|
|
69
|
+
/**
|
|
70
|
+
* Get registered oracle by type.
|
|
71
|
+
*
|
|
72
|
+
* @param type - Oracle type
|
|
73
|
+
* @returns Oracle instance or undefined
|
|
74
|
+
*/
|
|
75
|
+
GetOracle(type: string): IOracle | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Get all registered oracle types.
|
|
78
|
+
*
|
|
79
|
+
* @returns Array of oracle type names
|
|
80
|
+
*/
|
|
81
|
+
GetOracleTypes(): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Register built-in oracles.
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
private registerBuiltInOracles;
|
|
87
|
+
/**
|
|
88
|
+
* Get or create test driver instance.
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
private getDriver;
|
|
92
|
+
/**
|
|
93
|
+
* Get test entity from cache.
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
private loadTest;
|
|
97
|
+
/**
|
|
98
|
+
* Get suite entity from cache.
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
private loadSuite;
|
|
102
|
+
/**
|
|
103
|
+
* Get tests for a suite from cache (sorted by sequence).
|
|
104
|
+
* @private
|
|
105
|
+
*/
|
|
106
|
+
private loadSuiteTests;
|
|
107
|
+
/**
|
|
108
|
+
* Create TestRun entity.
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
private createTestRun;
|
|
112
|
+
/**
|
|
113
|
+
* Create TestSuiteRun entity.
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
private createSuiteRun;
|
|
117
|
+
/**
|
|
118
|
+
* Update TestRun entity with results.
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
private updateTestRun;
|
|
122
|
+
/**
|
|
123
|
+
* Update TestSuiteRun entity with results.
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
126
|
+
private updateSuiteRun;
|
|
127
|
+
/**
|
|
128
|
+
* Run a test multiple times for statistical analysis.
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
private runRepeatedTest;
|
|
132
|
+
/**
|
|
133
|
+
* Run a single test iteration (extracted from RunTest for reuse).
|
|
134
|
+
* @private
|
|
135
|
+
*/
|
|
136
|
+
private runSingleTestIteration;
|
|
137
|
+
/**
|
|
138
|
+
* Log execution progress.
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
private log;
|
|
142
|
+
/**
|
|
143
|
+
* Log errors.
|
|
144
|
+
* @private
|
|
145
|
+
*/
|
|
146
|
+
private logError;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=TestEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestEngine.d.ts","sourceRoot":"","sources":["../../src/engine/TestEngine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,QAAQ,EAKX,MAAM,sBAAsB,CAAC;AAS9B,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAM7C,OAAO,EACH,cAAc,EAEd,aAAa,EACb,kBAAkB,EACrB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,UAAW,SAAQ,cAAc;IAC1C,OAAO,CAAC,YAAY,CAAqC;IACzD,OAAO,CAAC,eAAe,CAA8B;IAErD;;OAEG;IACH,WAAkB,QAAQ,IAAI,UAAU,CAEvC;IAED;;OAEG;IACH,OAAO;cAIkB,iBAAiB,CAAC,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAajF;;;;;;;;OAQG;IACU,OAAO,CAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,QAAQ,EACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,EAC1B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAClC,OAAO,CAAC,aAAa,GAAG,aAAa,E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