-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBest-Practices.htm
More file actions
50 lines (50 loc) · 3.14 KB
/
Copy pathBest-Practices.htm
File metadata and controls
50 lines (50 loc) · 3.14 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
50
<p><a href="README.htm">Website Home Page</a></p>
<h1 id="best-practices">Best Practices</h1>
<hr />
<p>Place the <strong>"WTPLSQL_RUN" procedure at the end of the package body.</strong> This allows the procedure call any procedure/function in the package.</p>
<p>Place the <strong>"--% WTPLSQL SET DBOUT" annotation next to the WTPLSQL_RUN procedure</strong> definition in the package body.</p>
<pre><code> procedure WTPLSQL_RUN --% WTPLSQL SET DBOUT "MY_PACKAGE" %--
is
</code></pre>
<p><strong>Separate "setup" and "teardown" steps</strong> into their own Test Cases.**</p>
<p><strong>Use words consistently in Test Case names.</strong></p>
<ul>
<li>Use the word "Setup" in Test Case names perform setup operations.</li>
<li>Use the word "Teardown" in Test Case names that perform tear-down operations.</li>
<li>Use the words "Happy Path" in Test Case names that perform "happy path" tests.</li>
<li>Use the words "Sad Path" in Test Case names that perform "sad path" tests.
<ul>
<li>expected failure testing.</li>
<li>fault insertion testing.</li>
</ul></li>
</ul>
<p><strong>Include tests for boundary conditions</strong></p>
<ul>
<li>Largest and smallest values</li>
<li>Longest and shortest values</li>
<li>All combinations of default and non-default values</li>
</ul>
<p><strong>Create test procedures for each procedure/function</strong> in a DBOUT PACKAGE BODY.</p>
<ul>
<li>Call all test procedures from the WTPLSQL_RUN procedure.</li>
<li>Embed the test procedure just after the procedure/function it tests.</li>
<li>Use a consistent prefix on all test procedure names, like "t_".</li>
</ul>
<p><strong>Use conditional compilation</strong> select directive "WTPLSQL_ENABLE" in the Oracle database initialization parameter "PLSQL_CCFLAGS" to enable and disable embedded test code in all PACKAGE BODYs.</p>
<ul>
<li>"WTPLSQL_ENABLE:TRUE" will enable test code.</li>
<li>"WTPLSQL_ENABLE:FALSE" will disable test code.</li>
</ul>
<p><strong>Use consistent begin and end test code markers</strong> for embedded tests. These examples will setup conditional compiling and annotate lines of code to be excluded from code coverage calculations.</p>
<pre><code>$IF $$WTPLSQL_ENABLE -------%WTPLSQL_begin_ignore_lines%-------
$THEN
...
$END ----------------%WTPLSQL_end_ignore_lines%----------------
</code></pre>
<p><strong>Keep embedded test code indented</strong> between the test code markers</p>
<p><strong>Add WTPLSQL markers every 10 lines or less</strong> in an embedded procedure. This helps identify a long embedded test procedure while scrolling through source code. When in doubt, add more of these.</p>
<pre><code> -------------------------------------- WTPLSQL Testing --
</code></pre>
<p><strong>Check and/or set NLS settings before testing.</strong> Many data types are implicitly converted to VARCHAR2 before comparison. The "wtplsql" package includes functions to check and set NLS settings. Note: Modifying these settings always includes a COMMIT.</p>
<hr />
<p><a href="README.htm">Website Home Page</a></p>