|
| 1 | +PL/SQL Developer Test script 3.0 |
| 2 | +45 |
1 | 3 | --Shows how to create a test suite in code and call the test runner. |
2 | 4 | --No tables are used for this. |
3 | 5 | --Suite Management packages are when developed will make this easier. |
4 | | -Clear Screen |
5 | | -Set Serveroutput On Size Unlimited |
6 | | - |
7 | | -Declare |
8 | | - testtoexecute ut_types.single_test; |
9 | | - Suite Ut_Types.Test_Suite; |
10 | | - testresults ut_types.test_suite_results; |
11 | | -Begin |
12 | | - Suite.Suite_name := 'Test Suite Name'; |
13 | | - Suite.Tests := ut_Types.Test_List(); |
14 | | - |
15 | | - Testtoexecute.object_name := 'ut_exampletest'; |
16 | | - Testtoexecute.setup_procedure := 'Setup'; |
17 | | - TestToExecute.teardown_procedure := 'TearDown'; |
18 | | - TestToExecute.test_procedure := 'ut_exampletest'; |
19 | | - |
20 | | - Suite.Tests.Extend; |
21 | | - Suite.Tests(Suite.Tests.Last) := Testtoexecute; |
22 | | - |
23 | | - Testtoexecute.object_name := 'ut_exampletest2'; |
24 | | - Testtoexecute.setup_procedure := 'Setup'; |
25 | | - TestToExecute.teardown_procedure := 'TearDown'; |
26 | | - TestToExecute.test_procedure := 'ut_exampletest'; |
27 | | - |
28 | | - Suite.Tests.Extend; |
29 | | - Suite.Tests(Suite.Tests.LAST) := TestToExecute; |
30 | | - |
31 | | - ut_Test_Runner.Execute_Tests(Suite,null,TestResults); |
32 | | - |
33 | | - -- No reporter used in this example so outputing the results manually. |
34 | | - FOR test_idx in TestResults.first .. TestResults.last |
35 | | - LOOP |
36 | | - Dbms_Output.Put_Line('---------------------------------------------------'); |
37 | | - Dbms_Output.Put_Line('Test:' || Testresults(Test_Idx).Test.Object_Name || '.' || Testresults(Test_Idx).Test.Test_Procedure ); |
38 | | - dbms_output.put_line('Result: ' || Ut_Types.Test_Result_To_Char(TestResults(test_idx).result) ); |
39 | | - Dbms_Output.Put_Line('Assert Results:'); |
40 | | - FOR I in TestResults(test_idx).Assert_Results.First .. TestResults(test_idx).Assert_Results.Last |
41 | | - Loop |
42 | | - Dbms_Output.Put_Line(I || ' - result: ' || Ut_Types.Test_Result_To_Char(Testresults(Test_Idx).Assert_Results(I).Result) ); |
43 | | - dbms_output.put_line(I || ' - Message: ' || TestResults(test_idx).Assert_Results(I).Message); |
44 | | - END LOOP; |
45 | | - END LOOP; |
46 | | - dbms_output.put_line('---------------------------------------------------'); |
47 | | -End; |
48 | | -/ |
| 6 | +--Clear Screen |
| 7 | +--Set Serveroutput On Size Unlimited |
49 | 8 |
|
| 9 | +declare |
| 10 | + testtoexecute ut_single_test; |
| 11 | + suite ut_test_suite; |
| 12 | +-- testresults ut_suite_results; |
| 13 | + test_item ut_single_test; |
| 14 | +begin |
| 15 | + suite := ut_test_suite(a_suite_name => 'Test Suite Name' /*,a_tests => ut_Test_List()*/); |
| 16 | + |
| 17 | + testtoexecute := ut_single_test(a_object_name => 'ut_exampletest' |
| 18 | + ,a_test_procedure => 'ut_exAmpletest' |
| 19 | + ,a_setup_procedure => 'Setup' |
| 20 | + ,a_teardown_procedure => 'tEardown'); |
| 21 | + |
| 22 | + suite.add_test(testtoexecute); |
| 23 | + |
| 24 | + testtoexecute := ut_single_test(a_object_name => 'UT_EXAMPLETEST2' |
| 25 | + ,a_test_procedure => 'UT_EXAMPLETEST' |
| 26 | + ,a_setup_procedure => 'SETUP' |
| 27 | + ,a_teardown_procedure => 'TEARDOWN'); |
| 28 | + |
| 29 | + suite.add_test(testtoexecute); |
| 30 | + suite.execute; |
| 31 | + |
| 32 | + -- No reporter used in this example so outputing the results manually. |
| 33 | + for test_idx in suite.items.first .. suite.items.last loop |
| 34 | + test_item := treat(suite.items(test_idx) as ut_single_test); |
| 35 | + dbms_output.put_line('---------------------------------------------------'); |
| 36 | + dbms_output.put_line('Test:' || test_item.call_params.object_name || '.' || test_item.call_params.test_procedure); |
| 37 | + dbms_output.put_line('Result: ' || test_item.execution_result.result_to_char); |
| 38 | + dbms_output.put_line('Assert Results:'); |
| 39 | + for i in test_item.assert_results.first .. test_item.assert_results.last loop |
| 40 | + dbms_output.put_line(i || ' - result: ' || |
| 41 | + test_item.assert_results(i).result_to_char); |
| 42 | + dbms_output.put_line(i || ' - Message: ' || test_item.assert_results(i).message); |
| 43 | + end loop; |
| 44 | + end loop; |
| 45 | + dbms_output.put_line('---------------------------------------------------'); |
| 46 | +end; |
| 47 | + |
| 48 | +0 |
| 49 | +4 |
| 50 | +call_params.owner |
| 51 | + |
| 52 | +schema |
| 53 | +part1 |
0 commit comments