You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ These are the working definitions for the wtPLSQL project.
66
66
67
67
**Testcase** - A logical grouping of assertions to run happy path, decision tree, boundary condition, and/or fault insertion tests. May included one or more setup, teardown, and intermediate setups.
68
68
69
-
**Test Runner** - A PL/SQL package that exercises a DBOUT and uses assertions to confirm the correct funcionality of the DBOUT. It may have zero or more testcases. It always contains a call to the WTPLSQL.TEST_RUN procedure. It may contain DBOUT annotations and/or "exclude source lines" annotations.
69
+
**Test Runner** - A PL/SQL package that exercises a DBOUT and uses assertions to confirm the correct funcionality of the DBOUT. It may have zero or more testcases. It always contains a call to the WTPLSQL.TEST_RUN procedure. It may contain DBOUT annotations and "ignore source lines" annotations.
70
70
71
71
The [Other Definitions page](Other-Definitions.md) includes definitions from many sources to help define the terms used in various software testing methodologies.
Copy file name to clipboardExpand all lines: docs/demo/Test-Runner.md
+96-20Lines changed: 96 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,15 @@
5
5
---
6
6
Most all wtPLSQL tests are executed with a Test Runner. A Test Runner is a PL/SQL package written by the tester. Below are examples of very simple Test Runners.
7
7
8
-
Minimal Test Runner Package Spec:
8
+
Run this:
9
+
9
10
```
10
-
create or replace package simple_test_runner authid current_user
11
+
create or replace package simple_test_runner authid definer
11
12
as
12
13
procedure wtplsql_run;
13
14
end simple_test_runner;
14
15
/
15
-
```
16
-
Minimal Test Runner Package Body:
17
-
```
16
+
18
17
create or replace package body simple_test_runner
19
18
as
20
19
procedure wtplsql_run is begin
@@ -25,19 +24,23 @@ as
25
24
end simple_test_runner;
26
25
/
27
26
```
28
-
This is a minimal test runner. It is a package that contains the (public) WTPLSQL_RUN procedure and 1 assertion. It does the same assertion as the ad-hoc assertion in the "Simple Test" page. However, the test results are not sent to DBMS_OUTPUT. The test results are saved in the wtPLSQL tables.
27
+
28
+
SIMPLE_TEST_RUNNER is a minimal test runner. It is a package that contains the (public) WTPLSQL_RUN procedure and 1 assertion. It does the same assertion as the ad-hoc assertion in the [Simple Test](Simple-Test.md) page.
29
29
30
30
## Execute and Display
31
31
32
32
To execute the Test Runner, run this:
33
+
33
34
```
34
35
begin
35
36
wtplsql.test_run('SIMPLE_TEST_RUNNER');
36
37
end;
37
38
/
38
39
```
39
40
40
-
The results for this assertion have been saved in the wtPLSQL tables. Use the default reporting package to display the results.
41
+
There are no test results because the test results were not sent to DBMS_OUTPUT. The test results were saved in the wtPLSQL tables.
42
+
43
+
To view the results, run this:
41
44
42
45
```
43
46
set serveroutput on size unlimited format word_wrapped
@@ -46,23 +49,29 @@ begin
46
49
wt_text_report.dbms_out;
47
50
end;
48
51
/
52
+
```
53
+
54
+
And get this:
49
55
56
+
```
50
57
wtPLSQL 1.1.0 - Run ID 12: 15-Jun-2018 01:45:16 PM
51
58
52
59
Test Results for WTP_DEMO.SIMPLE_TEST_RUNNER
53
-
Total Testcases: 0 Total Assertions: 1
60
+
Total Test Cases: 0 Total Assertions: 1
54
61
Minimum Interval msec: 56 Failed Assertions: 0
55
62
Average Interval msec: 56 Error Assertions: 0
56
63
Maximum Interval msec: 56 Test Yield: 100.00%
57
64
Total Run Time (sec): 0.2
58
65
```
59
66
60
-
While the results might vary, this is latest test result summary from all Test Runners for the login user. The report confirms that one assertion was executed for SIMPLE_TEST_RUNNER and it passed.
67
+
This is latest test result summary from all Test Runners for the login user. The interval time shown here is the elapsed time from starting the Test Runner until the first assertion was executed. The total run time is the elapsed time from start to finish for the Test Runner. The report confirms that one assertion was executed for SIMPLE_TEST_RUNNER and it passed. All tests passed, so the test yield is 100%.
61
68
62
69
## WT_TEXT_REPORT Display Levels
63
70
64
71
This example shows all result details for the SIMPLE_TEST_RUNNER only.
65
72
73
+
Run this:
74
+
66
75
```
67
76
set serveroutput on size unlimited format word_wrapped
68
77
@@ -71,11 +80,15 @@ begin
71
80
,in_detail_level => 30);
72
81
end;
73
82
/
83
+
```
74
84
85
+
And get this:
86
+
87
+
```
75
88
wtPLSQL 1.1.0 - Run ID 12: 15-Jun-2018 01:45:16 PM
A detail level of 30 shows all summary and detail results for a Test Runner. In this case, the summary is the same and the detailed results of the EQ assertion are shown. These detail levels are explained in the [Reference Page](../Reference.md).
102
+
This shows the latest test result summary with test results details. A detail level of 30 shows summary and detailed test results for a Test Runner. In this case, the summary is the same and the detailed results of the EQ assertion are shown. These detail levels are explained in the [Reference Page](../Reference.md).
103
+
104
+
The detailed results shown are the same as the ad-hoc result, with a "56ms" added. The detailed results from the Test Runner includes the elapsed time between assertions, or elapsed time from Test Runner startup to the first assertion.
90
105
91
106
## Test Cases
92
107
93
-
For wtPLSQL, a test case is a collection of assertions. Test results can be grouped by test case name. There can be zero or more test cases in a Test Runner.
108
+
For wtPLSQL, a test case is a collection of assertions. Assertion results can be grouped by test case. There can be zero or more test cases in a Test Runner.
109
+
110
+
Run this:
94
111
95
112
```
96
113
create or replace package body simple_test_runner
97
114
as
98
115
procedure wtplsql_run is begin
99
-
wt_assert.g_testcase := 'My Test Case';
100
-
wt_assert.eq(msg_in => 'Ad-Hoc Test'
116
+
wt_assert.g_testcase := 'My Test Case A';
117
+
wt_assert.eq(msg_in => 'Ad-Hoc Test1'
101
118
,check_this_in => 1
102
119
,against_this_in => '1');
120
+
wt_assert.eq(msg_in => 'Ad-Hoc Test2'
121
+
,check_this_in => 2
122
+
,against_this_in => '2');
123
+
wt_assert.g_testcase := 'My Test Case B';
124
+
wt_assert.eq(msg_in => 'Ad-Hoc Test1'
125
+
,check_this_in => 4
126
+
,against_this_in => ' 4');
127
+
wt_assert.eq(msg_in => 'Ad-Hoc Test2'
128
+
,check_this_in => 5
129
+
,against_this_in => to_number(' 5'));
103
130
end wtplsql_run;
104
131
end simple_test_runner;
105
132
/
106
133
```
107
134
108
-
This modification of the SIMPLE_TEST_RUNNER sets a test case for the assertion. It is done by modifying a WT_ASSERT package variable. More on this below.
135
+
Setting a value for WT_ASSERT.G_TESTCASE in the SIMPLE_TEST_RUNNER package sets a test case for all following assertions. This value can be set multiple times within a Test Runner. The results summary will show the number of test cases. The test results details will group assertions by test case.
The Test Results summary shows 2 test cases were found. The Test Results Details show the assertion results grouped by test case. The details also show a failed assertion. It also shows "Ad-Hoc Test2" in "My Test Case B" passed because the TO_NUMBER was used to remove the space character from " 5".
110
171
111
172
## DBOUT Annotation
112
173
113
174
The Database Object Under Test (DBOUT) annotation is used to determine which database object to profile. If this annotation identifies accessible source code for a DBOUT, the DBMS_PROFILER package is activated to check code coverage.
114
175
176
+
Run this:
177
+
115
178
```
116
179
create or replace package body simple_test_runner
117
180
as
118
181
--% WTPLSQL SET DBOUT "SIMPLE_TEST_RUNNER:PACKAGE BODY" %--
119
182
procedure wtplsql_run is begin
120
-
wt_assert.g_testcase := 'My Test Case';
121
183
wt_assert.eq(msg_in => 'Ad-Hoc Test'
122
184
,check_this_in => 1
123
185
,against_this_in => '1');
@@ -128,17 +190,23 @@ end simple_test_runner;
128
190
129
191
With the addition of the DBOUT annotation, the profiling information is available for the SIMPLE_TEST_RUNNER package.
wtPLSQL 1.1.0 - Run ID 38: 15-Jun-2018 11:03:52 PM
139
207
140
208
Test Results for WTP_DEMO.SIMPLE_TEST_RUNNER
141
-
Total Testcases: 1 Total Assertions: 1
209
+
Total Test Cases: 0 Total Assertions: 1
142
210
Minimum Interval msec: 186 Failed Assertions: 0
143
211
Average Interval msec: 186 Error Assertions: 0
144
212
Maximum Interval msec: 186 Test Yield: 100.00%
@@ -153,13 +221,15 @@ end;
153
221
Trigger Source Offset: 0
154
222
```
155
223
156
-
Note the addition of the "Code Coverage" Summary. DBMS_PROFILER found 4 lines of significance in the source code. 3 of those lines were executed. 1 line is unknown or undefined by DBMS_PROFILER. Unknown lines consume execution time, but were not executed.
224
+
This shows the latest test result summary and code coverage summary for the SIMPLE_TEST_RUNNER test runner. DBMS_PROFILER found 4 lines of significance in the source code. 3 of those lines were executed. 1 line is unknown or undefined by DBMS_PROFILER. Unknown lines consume execution time, but were not executed.
157
225
158
226
## Ignore Annotation
159
227
160
228
In the previous example, the SIMPLE_TEST_RUNNER package is both the Test Runner and the Database Object Under Test (DBOUT). In practice, this is a self testing package. Because DBMS_OUTPUT includes all the source lines, there is a need to segregate "testing" source lines from "tested" source lines. The ignore annotation is used to segregate these lines.
161
229
162
-
The function "add2" represents some code that needs to be tested. It is also a private function. Self testing packages can run private functions.
230
+
The function "add2" represents some code that needs to be tested. It is also a private function. Self testing packages can test the private functions in the package.
231
+
232
+
Run this:
163
233
164
234
```
165
235
create or replace package body simple_test_runner
@@ -185,17 +255,23 @@ The DBOUT annotation has been moved for convenience. It can be placed anywhere
185
255
186
256
The "begin_ignore" and "end_ignore" annotations have been added to the SIMPLE_TEST_RUNNER package. The intent of these annotations is to ignore the source lines for the WTPLSQL_RUN procedure for code coverage calculations.
0 commit comments