1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The relax software verification tests.
24
25 For a description of verification tests, please see U{Wikipedia<https://en.wikipedia.org/wiki/Verification_and_validation_%28software%29>}.
26 """
27
28
29 from re import search
30 from unittest import TestSuite
31
32
33 from lib.errors import RelaxError
34
35
36 from test_suite.relax_test_loader import RelaxTestLoader as TestLoader
37 from test_suite.verification_tests.library import Library
38 from test_suite.verification_tests.status_object import Status_object
39
40
41 __all__ = [
42 'library',
43 'status_object'
44 ]
45
46
48 """Class for executing all of the software verification tests."""
49
50 - def run(self, tests=None, runner=None):
51 """Run the software verification tests.
52
53 @keyword tests: The list of system tests to preform.
54 @type tests: list of str
55 @keyword runner: A test runner such as TextTestRunner. For an example of how to write a test runner see the python documentation for TextTestRunner in the python source.
56 @type runner: Test runner instance (TextTestRunner, BaseGUITestRunner subclass, etc.)
57 """
58
59
60 suite_array = []
61
62
63 for test in tests:
64
65 if not search('\.', test):
66
67 if test not in globals():
68 raise RelaxError("The system test class '%s' does not exist." % test)
69
70
71 obj = globals()[test]
72
73
74 suite_array.append(TestLoader().loadTestsFromTestCase(obj))
75
76
77 else:
78
79 row = test.split('.')
80
81
82 if len(row) != 2:
83 raise RelaxError("The test '%s' is not in the correct format. It should consist of the test case class, a dot, and the specific test." % test)
84
85
86 class_name, test_name = row
87
88
89 obj = globals()[class_name]
90
91
92 suite_array.append(TestLoader().loadTestsFromNames([test_name], obj))
93
94
95 if not tests:
96 suite_array.append(TestLoader().loadTestsFromTestCase(Library))
97 suite_array.append(TestLoader().loadTestsFromTestCase(Status_object))
98
99
100 full_suite = TestSuite(suite_array)
101
102
103 results = runner.run(full_suite)
104
105
106 return results.wasSuccessful()
107