Skip to content

Commit 6dceff6

Browse files
committed
Add htm files
1 parent c96a4bf commit 6dceff6

19 files changed

+1074
-9
lines changed

docs/About-wtPLSQL.htm

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<p><a href="README.htm">Website Home Page</a></p>
2+
<h1 id="about-wtplsql">About wtPLSQL</h1>
3+
<hr />
4+
<h2 id="history">History</h2>
5+
<p>Following are some links regarding the history of utPLSQL.</p>
6+
<p><a href="http://archive.oreilly.com/pub/a/oreilly/oracle/utplsql/">Steven Feuerstein Designed and Developed utPLSQL (V1)</a></p>
7+
<p><a href="http://stevenfeuersteinonplsql.blogspot.com/2015/03/recommendations-for-unit-testing-plsql.html">Steven Feuerstein's Recommendations for Unit Testing PL/SQL Programs</a></p>
8+
<p><a href="https://utplsql.org/utPLSQL/v2.3.1/">utPLSQL V2 Documentation</a></p>
9+
<p><a href="https://utplsql.org/">utPLSQL V3 Website</a></p>
10+
<h2 id="background">Background</h2>
11+
<p>Because of his reputation with Oracle's PL/SQL, Steven Feuerstein's utPLSQL has been widely adopted. However, maintenance of the utPLSQL source code became a problem with the latest utPLSQL V2 releases. Inspection of the utPLSQL V2 source code revealed some very complex code pathways. Much of this resulted from the layering of the V1 API on top of the V2 implementation. There is no documentation on how the V1 layering was intended to work. There is no documentation on the overall design of the V2 implementation. There is no documentation on how to use the V2 API. (Kudos to <a href="https://github.com/PaulWalkerUK">@PaulWalkerUK</a> for an amazing job of maintaining the V2 code set.) As a result, most all unit tests written with utPLSQL V2 use the V1 APIs.</p>
12+
<p>The utPLSQL V3 project was started with a &quot;clean sheet&quot; approach. The project took a distinctly object oriented direction. This is apropos, given that Steven Feuerstein subtitles utPLSQL as &quot;JUnit for PLSQL&quot;. The V3 project has also adopted other aspects of JUnit testing like annotations. It is a clever and useful approach and will be familiar to Java developers. <a href="https://github.com/jgebal">@jgebal</a> was part of the utPLSQL V3 development from the beginning and continues to provide excellent contributions and information for that project.</p>
13+
<p>Before the &quot;clean sheet&quot; approach was adopted, the V3 team reviewed what has been published as the <a href="https://github.com/DDieterich/utplsql_lite">utPLSQL_Lite project</a>. The utPSQL_Lite project was an effort to create a simplified utPLSQL core with the use of options/add-ons to achieve additional functionality.</p>
14+
<p>The wtPLSQL project is a continuation of the utPLSQL_Lite project.</p>
15+
<h2 id="goals">Goals</h2>
16+
<p>This project focuses on providing a <strong>simple</strong>, yet <strong>robust</strong>, framework for <strong>dynamic</strong>, <strong>white box</strong> testing of <strong>Oracle Database Objects</strong>.</p>
17+
<h3 id="simple-framework">Simple Framework</h3>
18+
<p><a href="https://martinfowler.com/bliki/Xunit.html">Kent wants people to control their own environment, so he liked to have each team build the framework themselves</a></p>
19+
<p>The wtPLSQL project is an attempt to allow PL/SQL developers to be PL/SQL developers. The test runners are entirely user-written in PL/SQL. The framework supplies resources for collecting and reporting information from those test runners. Through its simplified architecture and open source approach, extensions of the functionality are relatively easy.</p>
20+
<h3 id="robust-framework">Robust Framework</h3>
21+
<p><a href="https://en.wikipedia.org/wiki/Robustness_(computer_science)">Robustness is the ability of a computer system to cope with errors during execution</a></p>
22+
<p>The wtPLSQL framework includes provisions for the following errors during execution:</p>
23+
<ul>
24+
<li>Un-handled test runner exceptions</li>
25+
<li>Storage errors from too many old test result sets.</li>
26+
<li>Isolation of different test runner results during concurrent test runs.</li>
27+
<li>Missing or non-existent test runners.</li>
28+
<li>Incorrect/incompatable DBMS_PROFILER version</li>
29+
</ul>
30+
<h3 id="dynamic-testing">Dynamic Testing</h3>
31+
<p><a href="https://en.wikipedia.org/wiki/Software_testing#Static_vs._dynamic_testing">Testing that takes place when the program itself is run.</a></p>
32+
<p>The wtPLSQL framework supports testing of source code during its execution. That is, the source code is executed during testing. It is not a static code analyzer or a guide for review meetings.</p>
33+
<h3 id="white-box-testing">White Box Testing</h3>
34+
<p><a href="https://en.wikipedia.org/wiki/Software_testing#White-box_testing">Tests internal structures or workings of a program</a></p>
35+
<p>The <a href="https://en.wikipedia.org/wiki/White-box_testing#Overview">essence of white box testing</a> is the careful testing of the application at the source code level to prevent any hidden errors later on. A key measure of completeness for this kind of testing is the <a href="https://en.wikipedia.org/wiki/Code_coverage">code coverage</a> of the test. A complete white box test will achieve 100% code coverage. This does not guarantee all aspects of the code have been tested, but it does ensure that all code pathways have been tested.</p>
36+
<p>An important part of establishing code coverage is identifying what code is being tested. The wtPLSQL framework uses a DBOUT (DataBase Object Under Test) to identify the code being tested. Upon identifying the DBOUT, the framework can gather and report information regarding code coverage.</p>
37+
<h3 id="oracle-database-objects">Oracle Database Objects</h3>
38+
<p><a href="https://docs.oracle.com/database/122/CNCPT/tables-and-table-clusters.htm#GUID-7567BE77-AFC0-446C-832A-FCC1337DEED8">Some of the (database) objects that schemas can contain are Packages, Procedures, Functions, Triggers, and Views.</a></p>
39+
<p>Many kinds of database objects need to be tested, not just packages. Triggers containing PL/SQL need to be tested. With the addition of <a href="https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/SELECT.html#GUID-CFA006CA-6FF1-4972-821E-6996142A51C6__BABJFIDC">inline functions in SQL</a>, views can contain PL/SQL as well. <a href="https://docs.oracle.com/database/122/ADOBJ/object-methods.htm#ADOBJ00202">Oracle Type Bodies</a> also include PL/SQL procedures and functions. All of these database objects can be tested with wtPSQL.</p>
40+
<p>In the wtPLSQL framework, the DBOUT can be any of the following PL/SQL objects:</p>
41+
<ul>
42+
<li>Packages</li>
43+
<li>Procedures (standalone)</li>
44+
<li>Functions (standalone)</li>
45+
<li>Triggers</li>
46+
<li>Views (Not yet implemented)</li>
47+
</ul>
48+
<h3 id="embedded-selftest">Embedded Selftest</h3>
49+
<p><a href="https://utplsql.org/utPLSQL/v2.3.1/samepack.html">Put Test Code in Same Package</a></p>
50+
<p>With utPLSQL V1/V2, packages can include an embedded self-test. The required calls can be exposed within the package that is being tested. This is particularly useful for testing package internals like private variables and procedures. These embedded selftests also remove the need to expose private variables and procedures to public calls so they can be tested.</p>
51+
<p>wtPLSQL continues this capability. However, with wtPLSQL, the addition of an embedded selftest requires only 1 additional procedure call in the package specification (WTPLSQL_RUN).</p>
52+
<h2 id="unit-testing">Unit Testing</h2>
53+
<p>As mentioned above, white box testing can occur at various levels of development, including:</p>
54+
<ul>
55+
<li><strong>unit testing</strong></li>
56+
<li>integration testing</li>
57+
<li>regression testing.</li>
58+
</ul>
59+
<p>The wtPLSQL project focuses on white box testing instead of <strong>unit testing</strong> in order to avoid some controversial aspects of unit testing, namely Test Isolation and Test Transience.</p>
60+
<h3 id="test-isolation">Test Isolation</h3>
61+
<p>A unit test should <a href="https://en.wikipedia.org/wiki/Unit_testing#Description">usually not go outside of its own class boundary</a></p>
62+
<p>In OO (object oriented) programming, object data is transient. This is due to the nature of object instantiation. Persistence of object data beyond the instance of an object is banished to non-OO components. Since the unit test movement gained its largest following in OO, the idea of testing persisted object data is, unfortunately, a distraction. This has evolved into the idea that testing a database interface should always involve the use of a <a href="https://en.wikipedia.org/wiki/Test-driven_development#Fakes.2C_mocks_and_integration_tests">fake or mock</a> to <strong>isolate</strong> the unit under test from the influence of these non-OO components.</p>
63+
<p>Transactional data (ACID compliance) introduces a complexity to the persistence of object data. Attempting to fake this complexity is very difficult. Particularly difficult is the determination of how much functionality to include in the fake, especially when the storage of the data is the main purpose for the system. Focusing on white box testing, instead of unit testing, allows the wtPLSQL framework to test integrated functionality from other system components.</p>
64+
<h3 id="test-transience">Test Transience</h3>
65+
<p>A unit test should set up a known good state before the tests and <a href="https://en.wikipedia.org/wiki/XUnit#Test_fixtures">return to the original state after the tests</a></p>
66+
<p>There are many arguments to be made regarding the idea of a known good state in a database. The only sure way to achieve a known good state is to leave the the database unchanged after a unit test. Ideally, changes made by a test process would be <strong>transient</strong>, that is the process would setup (insert) and tear down (delete) data in the database. However, many Oracle database implementations include additional functionality that can make this difficult.</p>
67+
<ul>
68+
<li>Complex data setup</li>
69+
<li>Additional processing that is unknown or poorly defined</li>
70+
<li>Built-in auditing</li>
71+
</ul>
72+
<p>In the wtPLSQL framework, integration testing of multiple database objects (no mocks or fakes) is allowed (i.e. not bound by the <strong>transience</strong> aspect). Artifacts from multiple test runs can remain in the database after the testing is complete. Additionally, artifacts that remain after testing can help identify other problems in the database.</p>
73+
<h3 id="test-fixtures-and-test-suites">Test Fixtures and Test Suites</h3>
74+
<p><a href="https://en.wikipedia.org/wiki/XUnit#Test_fixtures">A test fixture ... is the set of preconditions or state needed to run a test</a></p>
75+
<p><a href="https://en.wikipedia.org/wiki/XUnit#Test_suites">A test suite is a set of tests that all share the same fixture.</a></p>
76+
<p>Test fixtures and test suites are a part of the xUnit testing framework. At the core, wtPLSQL does not include test fixtures or test suites. If needed, these can be easily defined and implemented in a test runner package.</p>
77+
<h2 id="test-driven-development">Test Driven Development</h2>
78+
<p>With <strong>TDD</strong> (Test Driven Development), <a href="http://agiledata.org/essays/tdd.html">you write a test before you write just enough production code to fulfill that test</a></p>
79+
<p>The wtPLSQL framework is not intended for Test Driven Development. 100% code coverage is not desirable under the <strong>TDD</strong> approach. Test isolation and test transience are welcomed mechanisms to assist in getting tests to pass quickly in <strong>TDD</strong>. The wtPLSQL framework embraces 100% code coverage and does not require test isolation or test transience.</p>
80+
<hr />
81+
<p><a href="README.htm">Website Home Page</a></p>

docs/Best-Practices.htm

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<p><a href="README.htm">Website Home Page</a></p>
2+
<h1 id="best-practices">Best Practices</h1>
3+
<hr />
4+
<p>Place the <strong>&quot;WTPLSQL_RUN&quot; procedure at the end of the package body.</strong> This allows the procedure call any procedure/function in the package.</p>
5+
<p>Place the <strong>&quot;--% WTPLSQL SET DBOUT&quot; annotation next to the WTPLSQL_RUN procedure</strong> definition in the package body.</p>
6+
<pre><code> procedure WTPLSQL_RUN --% WTPLSQL SET DBOUT &quot;MY_PACKAGE&quot; %--
7+
is
8+
</code></pre>
9+
<p><strong>Separate &quot;setup&quot; and &quot;teardown&quot; steps</strong> into their own Test Cases.**</p>
10+
<p><strong>Use words consistently in Test Case names.</strong></p>
11+
<ul>
12+
<li>Use the word &quot;Setup&quot; in Test Case names perform setup operations.</li>
13+
<li>Use the word &quot;Teardown&quot; in Test Case names that perform tear-down operations.</li>
14+
<li>Use the words &quot;Happy Path&quot; in Test Case names that perform &quot;happy path&quot; tests.</li>
15+
<li>Use the words &quot;Sad Path&quot; in Test Case names that perform &quot;sad path&quot; tests.
16+
<ul>
17+
<li>expected failure testing.</li>
18+
<li>fault insertion testing.</li>
19+
</ul></li>
20+
</ul>
21+
<p><strong>Include tests for boundary conditions</strong></p>
22+
<ul>
23+
<li>Largest and smallest values</li>
24+
<li>Longest and shortest values</li>
25+
<li>All combinations of default and non-default values</li>
26+
</ul>
27+
<p><strong>Create test procedures for each procedure/function</strong> in a DBOUT PACKAGE BODY.</p>
28+
<ul>
29+
<li>Call all test procedures from the WTPLSQL_RUN procedure.</li>
30+
<li>Embed the test procedure just after the procedure/function it tests.</li>
31+
<li>Use a consistent prefix on all test procedure names, like &quot;t_&quot;.</li>
32+
</ul>
33+
<p><strong>Use conditional compilation</strong> select directive &quot;WTPLSQL_ENABLE&quot; in the Oracle database initialization parameter &quot;PLSQL_CCFLAGS&quot; to enable and disable embedded test code in all PACKAGE BODYs.</p>
34+
<ul>
35+
<li>&quot;WTPLSQL_ENABLE:TRUE&quot; will enable test code.</li>
36+
<li>&quot;WTPLSQL_ENABLE:FALSE&quot; will disable test code.</li>
37+
</ul>
38+
<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>
39+
<pre><code>$IF $$WTPLSQL_ENABLE -------%WTPLSQL_begin_ignore_lines%-------
40+
$THEN
41+
...
42+
$END ----------------%WTPLSQL_end_ignore_lines%----------------
43+
</code></pre>
44+
<p><strong>Keep embedded test code indented</strong> between the test code markers</p>
45+
<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>
46+
<pre><code> -------------------------------------- WTPLSQL Testing --
47+
</code></pre>
48+
<p><strong>Check and/or set NLS settings before testing.</strong> Many data types are implicitly converted to VARCHAR2 before comparison. The &quot;wtplsql&quot; package includes functions to check and set NLS settings. Note: Modifying these settings always includes a COMMIT.</p>
49+
<hr />
50+
<p><a href="README.htm">Website Home Page</a></p>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy