initial thoughts on framework
[platform/upstream/gstreamer.git] / docs / random / omega / testing / framework
1 Construction
2 Validation
3 Testing
4
5 Construction will generate some state
6 Validation will ensure that everything is kosher
7 Tests use combinations of the above to check things
8
9 ##### Example:
10 parent = gst_object_get_parent(object);
11
12 setup:
13         create: new object
14                 action: object = gst_object_new();
15                 validation: object != NULL, object->parent == NULL, etc
16                 [cleanup: gst_object_destroy(object);]
17         create: new parent
18                 action: parent = gst_object_new();
19                 validation: parent != NULL, parent->parent == NULL, etc
20                 [cleanup: gst_object_destroy(parent);]
21         create: set object's parent
22                 precondition: object->parent == NULL
23                 action: gst_object_set_parent(object,parent);
24                 validation: object->parent = parent
25 preconditions:
26         nothing
27 action:
28         curparent = gst_element_get_parent(object);
29 validaton:
30         curparent == object->parent
31         curparent == parent
32 cleanup:
33         nothing
34
35
36 ##### Resulting code:
37
38 ///// setup
39 // new object
40 object = gst_object_new();
41 ASSERT(object != NULL);
42 ASSERT(object->parent == NULL);
43 // new object
44 parent = gst_object_new();
45 ASSERT(parent != NULL);
46 ASSERT(parent->parent == NULL);
47 // set object parent
48 ASSERT(object->parent == NULL);
49 gst_object_set_parent(object,parent);
50 ASSERT(object->parent != NULL);
51
52 ///// preconditions
53
54 ///// action
55 curparent = gst_element_get_parent(object);
56
57 ///// validation
58 ASSERT(object->parent == parent);
59
60 ///// cleanup
61 gst_object_destroy(parent);
62 gst_object_destroy(object);
63
64
65
66 ##### XML descriptions
67
68 <setup name="new object">
69   <variable>
70     GstObject *object;
71   </variabls>
72   <action>
73     object = gst_object_new();
74   </action>
75   <validation>
76     <assert>
77       object != NULL
78     </assert>
79     <assert>
80       GST_IS_OBJECT(object)
81     <assert>
82       object->parent == NULL
83     </assert>
84   </validation>
85   <cleanup>
86     <validation>
87       <assert>
88         object != NULL
89       </assert>
90       <assert>
91         GST_IS_OBJECT(object)
92       </assert>
93     </validation>
94     <action>
95       gst_object_destroy(object);
96     </action>
97   </cleanup>
98 </setup>
99
100 . . .