-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadaptive_test_generator.py
More file actions
49 lines (33 loc) · 1.2 KB
/
adaptive_test_generator.py
File metadata and controls
49 lines (33 loc) · 1.2 KB
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
class AdaptiveTestGenerator:
"""
Generates new tests from system failures.
"""
def __init__(self):
self.generated_tests = []
# =====================================================
# EXTRACT FAILURE SIGNALS
# =====================================================
def mine_failures(self, execution_logs):
failures = []
for log in execution_logs:
if log.get("error") or log.get("result", 1.0) < 0:
failures.append(log)
return failures
# =====================================================
# CONVERT FAILURE → TEST CASE
# =====================================================
def synthesize_tests(self, failures):
tests = []
for f in failures:
tests.append({
"input_state": f.get("state"),
"expected_behavior": "no_crash",
"failure_context": f
})
self.generated_tests.extend(tests)
return tests
# =====================================================
# GET FULL TEST SUITE
# =====================================================
def get_tests(self):
return self.generated_tests