Thread: Is testing really matter at PL/SQL


Permlink Replies: 16 - Pages: 2 [ 1 2 | Next ] - Last Post: Aug 14, 2007 10:12 AM Last Post By: Hans Forbrich
Yawei Zhang

Posts: 439
Registered: 05/06/06
Is testing really matter at PL/SQL
Posted: Aug 11, 2007 8:16 PM
Click to report abuse...   Click to reply to this thread Reply
I am reading a book: Learning Oracle PL/SQL by Bill Pribyl and
Steven Feuerstein

I am a newbie of PL/SQL and I got no other programming XPs. but in the very first of this book they are introducing something called: testing, to make some test programms /utilites.

I found that is very hard to make, is it neccessary?
JS1

Posts: 1,186
Registered: 06/22/07
Re: Is testing really matter at PL/SQL
Posted: Aug 11, 2007 11:31 PM   in response to: Yawei Zhang in response to: Yawei Zhang
Click to report abuse...   Click to reply to this thread Reply
You are going to need to give more detail to make this question make any sense
Hariharan M K

Posts: 194
Registered: 05/09/07
Re: Is testing really matter at PL/SQL
Posted: Aug 12, 2007 1:57 AM   in response to: Yawei Zhang in response to: Yawei Zhang
Click to report abuse...   Click to reply to this thread Reply
hi
there is nothing called testing in pl/sql. probably they would have asked u to test the code and practice them. can u plz post exactly what u have seen in the book
thanks
hari
Yawei Zhang

Posts: 439
Registered: 05/06/06
Re: Is testing really matter at PL/SQL
Posted: Aug 12, 2007 8:19 PM   in response to: Hariharan M K in response to: Hariharan M K
Click to report abuse...   Click to reply to this thread Reply
----we are buliding a libariay catalog as an example--
first we created the following two tables:

CREATE TABLE books (
isbn VARCHAR2(13) NOT NULL PRIMARY KEY,
title VARCHAR2(200),
summary VARCHAR2(2000),
author VARCHAR2(200)
date_published DATE,
page_count NUMBER
);

CREATE TABLE book_copies(
barcode_id VARCHAR2(100) NOT NULL PRIMARY KEY,
isbn VARCHAR2(13) FOREIGN KEY REFERENCES books (isbn)
);

then we created some fuction and procedure

barcode_id_in IN VARCHAR2, title_in IN VARCHAR2, author_in IN VARCHAR2,
page_count_in IN NUMBER, summary_in IN VARCHAR2 DEFAULT NULL,
date_published_in IN DATE DEFAULT NULL)
AS
BEGIN
/* check for reasonable inputs */

IF isbn_in IS NULL
THEN
RAISE VALUE_ERROR;
END IF;

/* put a record in the "books" table */

INSERT INTO books (isbn, title, summary, author, date_published, page_count)
VALUES (isbn_in, title_in, summary_in, author_in, date_published_in,
page_count_in);

/* if supplied, put a record in the "book_copies" table */

IF barcode_id_in IS NOT NULL
THEN
INSERT INTO book_copies (isbn, barcode_id)
VALUES (isbn_in, barcode_id_in);
END IF;

END add_book;
/

CREATE OR REPLACE FUNCTION book_copy_qty(isbn_in IN VARCHAR2)
RETURN NUMBER
AS
number_o_copies NUMBER := 0;
CURSOR bc_cur IS
SELECT COUNT(*)
FROM book_copies
WHERE isbn = isbn_in;
BEGIN
IF isbn_in IS NOT NULL
THEN
OPEN bc_cur;
FETCH bc_cur INTO number_o_copies;
CLOSE bc_cur;
END IF;
RETURN number_o_copies;
END;
/

-----------------------then here comes the testing issue---------------------------------
3.4 Make Your Code Resilient
You are probably eager to get going on making our sample application do more—so am I! But it is important to first make sure the code we've written so far works as flawlessly as it possibly can. That's why I'm going to take what might seem like a digression.

You've probably heard the expression garbage in, garbage out (GIGO). Maybe you've even uttered this phrase from time to time, or heard it over the phone from support staff; it's supposed to "explain" some nonsensical result (garbage out) by blaming faulty input (garbage in).

But is GIGO an inevitable state of affairs? Most programmers are incorrigible optimists when it comes to thinking about how their programs will be used. The assumption is tidy in, tidy out. Nobody wants to plan for inputs they consider to be "abnormal."

To avoid unanticipated digital squalor, we have to run test cases. To run good test cases means dreaming up various combinations of input data that we hope will break the program. Then we note the expected results...run the program...compare the output...fix the program...rerun the tests. Yep, that's a lot of bookkeeping that I would certainly prefer to avoid.

Hmm, lots of tedious executions of code with different inputs; this sounds like a good opportunity to write some utilities, doesn't it? Let's create one ourselves and see if we can make this testing stuff more fun—or at least automate the tiresome bits.

3.4.1 A Results-Checking Utility
First, I'd like to create a simple way that will compare two values and print out a "pass" message if they're the same, or a "fail" message if they differ. This test is enormously useful, since the basis of testing is comparing the actual output to the expected response. We'll probably use such a procedure every time we run a test. While we're at it, let's throw in a description for the test, so that when we call this a bunch of times back-to-back we can keep up with which tests have failed. Have a look at this "report equality" (reporteq) procedure:

CREATE OR REPLACE PROCEDURE reporteq (description IN VARCHAR2,
expected_value IN VARCHAR2, actual_value IN VARCHAR2) AS
BEGIN
DBMS_OUTPUT.PUT(description || ': ');

IF expected_value = actual_value
OR (expected_value IS NULL AND actual_value IS NULL)
THEN
DBMS_OUTPUT.PUT_LINE('PASSED');
ELSE
DBMS_OUTPUT.PUT_LINE('FAILED. Expected ' || expected_value
'; got ' actual_value);
END IF;
END;
/
Note that this version of the procedure compares strings (VARCHAR2s); we can also create similar procedures to handle numbers, dates, and Boolean values.

3.4.2 A "Unit Tester" for add_book
Armed with our first handy-dandy test utility, we will now write a program that will call the add_book procedure in a variety of ways—yes, even sending garbage to it. The hope is that add_book will take out the garbage "properly," and our reporteq program is going to help. I will present the rather long program (87 lines) in pieces to make it easier to understand. Also, I've annotated the code with line numbers to aid in making references to specific lines:

1 DECLARE
2 l_isbn VARCHAR2(13) := '1-56592-335-9';
3 l_title VARCHAR2(200) := 'Oracle PL/SQL Programming';
4 l_summary VARCHAR2(2000) := 'Reference for PL/SQL developers, '

5 'including examples and best practice recommendations.';
6 l_author varchar2(200) := 'Feuerstein, Steven, and Bill Pribyl';
7 l_date_published DATE := TO_DATE('01-SEP-1997', 'DD-MON-YYYY');
8 l_page_count NUMBER := 987;
9 l_barcode_id VARCHAR2(100) := '100000001';
10
11 CURSOR bookCountCur IS
12 SELECT COUNT(*) FROM books;
13
14 CURSOR copiesCountCur IS
15 SELECT COUNT(*) FROM book_copies;
16
17 CURSOR bookMatchCur IS
18 SELECT COUNT(*) FROM books
19 WHERE isbn = l_isbn AND title = l_title AND summary = l_summary
20 AND author = l_author AND date_published = l_date_published
21 AND page_count = l_page_count;
22
23 CURSOR copiesMatchCur IS
24 SELECT COUNT(*) FROM book_copies
25 WHERE isbn = l_isbn AND barcode_id = l_barcode_id;
26
27 how_many NUMBER;
28 l_sqlcode NUMBER;
Ah, let me interrupt here to comment a bit.

Lines 2-9. Here are declarations of local variables that hold normal values we can use in various tests. Storing them in variables makes our life a bit easier because we can just reuse the variables. The l_ prefix is a reminder that these are local variables.

Lines 11-12. This is the declaration of the program's first cursor. A cursor enables us to fetch values from the database via a SQL SELECT statement. This particular statement counts how many total records exist in the books table.

Lines 14-15. Similarly, this cursor lets us count the total number of book copies.

Lines 17-21. This cursor counts the number of books whose column values exactly match the values of the local variables.

Line 27. The how_many local variable temporarily stores the result of those "count" queries.

Line 28. The l_sqlcode variable temporarily stores the output from PL/SQL's built-in SQLCODE function; we'll explain that function a bit later in this section.

The execution section, shown in the following code, begins with a deletion of everything in our two database tables. This ensures that any table counts that we do are only counting the new test data, and not data that happens to be lying around from other runs. Obviously, you want to run this on your "scratch" database, not the real thing!

29 BEGIN
30 DELETE book_copies;
31 DELETE books;
32
33 add_book(isbn_in => l_isbn, barcode_id_in => l_barcode_id,
34 title_in => l_title, summary_in => l_summary, author_in => l_author,
35 date_published_in => l_date_published, page_count_in => l_page_count);
36
37 OPEN bookMatchCur;
38 FETCH bookMatchCur INTO how_many;
39 reporteqbool('add procedure, book fetch matches insert',
40 expected_value => TRUE, actual_value => bookMatchCur%FOUND);
41 CLOSE bookMatchCur;
42
Lines 33-41. Now we come to the first actual run of the add_book routine, which supplies all nominal inputs, and which we expect to work. This begins the test to determine if the book added properly. By opening the cursor and fetching from it, we can check to see if the record is present as expected. In lines 39-40 is a call to reporteqbool, a version of reporteq that operates on Boolean rather than string values. If the fetch was successful, bookMatchCur%FOUND will be true (you'll read more about this sort of test in Chapter 5).As line 41 illustrates, it's good practice to close cursors as soon as the program is through with them.

43 BEGIN
44 add_book(isbn_in => NULL, barcode_id_in => 'foo', title_in => 'foo',
45 summary_in => 'foo', author_in => 'foo',
46 date_published_in => SYSDATE, page_count_in => 0);
47 l_sqlcode := SQLCODE;
48 EXCEPTION
49 WHEN OTHERS THEN
50 l_sqlcode := SQLCODE;
51 END;
52
53 reporteq('add procedure, detection of NULL input',
54 expected_value => '-6502', actual_value => TO_CHAR(l_sqlcode));
55
Lines 43-54. Next test: let's try a null isbn to see if the input error detection works. If it does, the procedure is supposed to raise a NO_DATA_FOUND exception. Since we expect to see an exception, we want to put the text in a nested block. That way, we can handle the exception as the very next operation, rather than jumping to the end of the main block.

To be consistent with the other tests, we want to identify a single result variable to compare with the expected result. PL/SQL provides a special built-in function called SQLCODE that will have a non-zero value inside any exception handler. Since we want to use the result code outside the exception handler, line 50 assigns its value to l_sqlcode, which communicates the value as an argument to reporteq in lines 53 and 54.

Line 54 shows that we expect the result code to be -6502. This is the value PL/SQL assigns to SQLCODE when a NO_DATA_FOUND exception occurs.

56 OPEN bookCountCur;
57 FETCH bookCountCur INTO how_many;
58 reporteq('add procedure, book_record count', expected_value => '1',
59 actual_value => how_many);
60 CLOSE bookCountCur;
61
62 OPEN copiesCountCur;
63 FETCH copiesCountCur INTO how_many;
64 reporteq('add procedure, book_copy record count', expected_value => '1',
65 actual_value => how_many);
66 CLOSE copiesCountCur;
67
68 OPEN copiesMatchCur;
69 FETCH copiesMatchCur INTO how_many;
70 reporteqbool('add procedure, book copy fetch matches insert',
71 expected_value => TRUE, actual_value => copiesMatchCur%FOUND);
72 CLOSE copiesMatchCur;
73
Lines 56-72. More tests. These just determine whether the expected number of records exist in the tables.

74 BEGIN
75 add_book(isbn_in => l_isbn, barcode_id_in => l_barcode_id,
76 title_in => l_title, summary_in => l_summary, author_in => l_author,
77 date_published_in => l_date_published,
78 page_count_in => l_page_count);
79 l_sqlcode := SQLCODE;
80 EXCEPTION
81 WHEN OTHERS THEN
82 l_sqlcode := SQLCODE;
83 END;
84 reporteq('add procedure, detection of duplicate isbn',
85 expected_value => '-1', actual_value => l_sqlcode);
86 END;
87 /
Lines 74-85. Now let's test to ensure that attempting to add the same isbn a second time will raise an exception. We expect Oracle to set a SQLCODE of -1, which is what you get when you attempt to insert a record with the same primary key as an existing record. (This is really a test of the database design, but we might as well test it somewhere.)

That's the end of the test. Whew! Now, assuming that we have enabled SERVEROUTPUT (see Chapter 2), running this program from within SQL*Plus yields:

add procedure, book fetch matches insert: PASSED
add procedure, detection of NULL input: PASSED
add procedure, book_record count: PASSED
add procedure, book_copy record count: PASSED
add procedure, book copy fetch matches insert: PASSED
add procedure, detection of duplicate isbn: PASSED
As you may know, this block serves as a unit test.[4] It also serves as a permanent, recorded example of how to call the program, which is always a generous gift to leave to future generations of programmers. (By the way, "future generations" includes you, six months from now, after you've written another 75 programs and completely forgotten about this one!)

[4] The word "unit" refers to the individual program unit; it contrasts with other tests such as integrated tests, which help ensure that program units behave properly when assembled into an application.

3.4.3 Testing the book_copy_qty Function
This next routine is a unit tester for the book_copy_qty function. The principle of operation is the same as the previous unit testing program:

1 DECLARE
2 l_isbn VARCHAR2(13) := '1-56592-335-9';
3 l_isbn2 VARCHAR2(13) := '2-56592-335-9';
4 l_title VARCHAR2(200) := 'Oracle PL/SQL Programming';
5 l_summary VARCHAR2(2000) := 'Reference for PL/SQL developers, ' ||
6 'including examples and best practice recommendations.';
7 l_author varchar2(200) := 'Feuerstein, Steven, and Bill Pribyl';
8 l_date_published DATE := TO_DATE('01-SEP-1997', 'DD-MON-YYYY');
9 l_page_count NUMBER := 987;
10 l_barcode_id VARCHAR2(100) := '100000001';
11 l_barcode_id2 VARCHAR2(100) := '100000002';
12 l_barcode_id3 VARCHAR2(100) := '100000003';
13
14 how_many NUMBER;
15 BEGIN
16 DELETE book_copies;
17 DELETE books;
18
19 reporteq('book_copy_qty function, zero count', '0',
20 TO_CHAR(book_copy_qty(l_isbn)));
21
22 /* Lets assume that add_book is working properly */
23 add_book(isbn_in => l_isbn, barcode_id_in => l_barcode_id,
24 title_in => l_title, summary_in => l_summary, author_in => l_author,
25 date_published_in => l_date_published, page_count_in => l_page_count);
26
27 reporteq('book_copy_qty function, unit count', '1',
28 TO_CHAR(book_copy_qty(l_isbn)));
29
30 add_book_copy(isbn_in => l_isbn, barcode_id_in => l_barcode_id2);
31 add_book_copy(isbn_in => l_isbn, barcode_id_in => l_barcode_id3);
32
33 reporteq('book_copy_qty function, multi count', '3',
34 TO_CHAR(book_copy_qty(l_isbn)));
35
36 reporteq('book_copy_qty function, null ISBN', '0',
37 TO_CHAR(book_copy_qty(NULL)));
38 END;
39 /
Lines 30-31. These are calls to a procedure that I haven't illustrated. All they do is insert a record into the book_copies table.

Running the unit test results in:

book_copy_qty function, zero count: PASSED
book_copy_qty function, non-zero count: PASSED
book_copy_qty function, null ISBN: PASSED
which, of course, is what we had hoped to see.

3.4.4 Why So Much Trouble?
At this point some readers will be wondering why I've gone to so much trouble. Can't your average programmer just have a quick read of the code and see that it will work?

Well, that's the sort of thinking that makes someone an average programmer. That last check for a NULL value in lines 36-37 is a case in point. My final version of the add_book program passed the test, but to tell you the truth, I hadn't thought about this possibility in the original version (not shown in this book). Only when I started writing the unit test did it occur to me that I needed to consider at least three input cases: good, bad, and the eternal troublemaker, NULL. And only by forcing my mind to consider what the test should cover did I realize my omission; I just got lucky that it worked. Thinking about the test helps you traverse a different set of mental pathways, where you can often get a better angle into your code.

Much has been written about the psychology of software testing, but once you start writing your own unit tests, you may get enough insight to write your own book. Well, maybe you won't write a book, but there is something about testing that you just can't internalize until you've been through your own "Aha!" experiences.
Credits: Learning Oracle PL/SQL

Bill Pribyl
Steven Feuerstein
Publisher: O'Reilly
First Edition December 2001
ISBN: 0-596-00180-0, 424 pages

Billy Verreynne

Posts: 8,624
Registered: 05/27/99
Re: Is testing really matter at PL/SQL
Posted: Aug 13, 2007 12:42 AM   in response to: Yawei Zhang in response to: Yawei Zhang
Click to report abuse...   Click to reply to this thread Reply
> but in the very first of this book they are introducing something called:
testing, to make some test programms /utilites.
I found that is very hard to make, is it neccessary?

Yes. It is critical to create and maintain code that is robust.

You write a piece of code (function/procedure/package) that is suppose to do ABC.

How do you make sure that your code does ABC?

You test the code of course. You supply it data and parameters and what not, it executes, and then you check the results to ensure that the code did ABC successfully.

2 weeks later you need to make a slight modification to the code to cater for a new business rules. Now you have to repeat all the testing again.

What would be easier? Manually testing the code again? Trying to remember what were tested.. what test data was used, creating that test data again.. etc.

Or will it be easier to if you have written a test harness (code) to test that procedure? Which means you simply execute the test harness and it tests your code (with its new changes) again.

Or, manager wants to know what will happen if your code gets unexpected data input.. as this is what happened in production.In this case you simply change your test harness, provide a new test for that "unexpected data" - and then run the test against your code to determine what the impact is.. and whether or not ABC was successfully done by the code.

There's a lot of comment and approaches to how to go about designing, writing and using test harnesses.

But ignore that for the time being. The important factors are:
- CODE MUST BE TESTED
- AUTOMATE THE TESTING OF CODE

These are undeniable Best Practices in software engineering. And you would make a big mistake in not following these.
mlindsay

Posts: 38
Registered: 10/30/06
Re: Is testing really matter at PL/SQL
Posted: Aug 13, 2007 1:46 AM   in response to: Yawei Zhang in response to: Yawei Zhang
Click to report abuse...   Click to reply to this thread Reply
but in the very first of this book they are introducing something called:
testing, to make some test programms /utilites.
I found that is very hard to make, is it neccessary?

Unit testing is one of the most fundamental concepts in software engineering (more Universities should teach it from day 1).

I'm the first to admit it is not easy and there are many managers that will see it as a waste of time but believe me when you get good at it you end up writing better code, spend more time doing new code and less time fixing bugs in old code.

Billy has covered pretty much all the main points i.e. tests prove that your code does what you think, they also prove your code works after a change has been made, the most important is that you DO NOT want to be doing manual tests as they take too long and will not be done the same way every time.

there is a good framework for unit testing PL/SQL called utplsql, you'll find it here:http://utplsql.sourceforge.net/

It's based on the nunit framework that JUnit was built on so it is fairly standard. it is easy to install and pick up and it can be integrated into applications such as Cruise Control, can be used with ANT and there are nice Java tools such as JUTEX also. The important thing here is that these tools allow all your tests or a subset of tests to be ran automatically without any input for a developer they also produce reports letting you know what has passed/failed.

To finish up with (and apologies if this sounds harsh) all professional software engineers should produce unit tests for the code they write otherwise they are, in my opinion, not to be considered software engineers or professional but mere hobby programmers being paid by people to do a job.

Trust me in time you'll learn to appreciate the value of having a solid base of unit tests and will spend less time writing the following type of code:

dbms_output.put_line('Reached Here')
......statement
dbms_output.put_line('After Statement - OK')
Satyaki_De

Posts: 6,686
Registered: 12/20/06
Re: Is testing really matter at PL/SQL
Posted: Aug 13, 2007 2:41 AM   in response to: Yawei Zhang in response to: Yawei Zhang
Click to report abuse...   Click to reply to this thread Reply
In short, you should check that your product will always produced your favorite red apple and not green guava.

Regards.

Satyaki De.
John Spencer

Posts: 5,451
Registered: 07/09/99
Re: Is testing really matter at PL/SQL
Posted: Aug 13, 2007 6:30 AM   in response to: mlindsay in response to: mlindsay
Click to report abuse...   Click to reply to this thread Reply
"there is a good framework for unit testing PL/SQL called utplsql, you'll find it here"

Utlplsql was, of course, written by that same Steven Feuerstein, and my bet would be that if you looked at the source for it, you would find many of the test harness procedures he sets out in the book. :-)

John
mlindsay

Posts: 38
Registered: 10/30/06
Re: Is testing really matter at PL/SQL
Posted: Aug 13, 2007 7:38 AM   in response to: John Spencer in response to: John Spencer
Click to report abuse...   Click to reply to this thread Reply
Utlplsql was, of course, written by that same Steven Feuerstein, and my bet would be that if you looked at the source for it, you would find many of the test harness procedures he sets out in the book

Indeed, I suspect you'd win your bet having read the book in question and taken a look at the framework code ;-)

I should also say that Steven Feuerstein has also been involved in the development if the Quest Unit Tester for Oracle. The basic idea behind it is that you do not actually write the unit test code, you set your tests up using the UI and then let the tool generate the unit test code for you and also run it.

One of the reasons for creating this tool was because it was that PL/SQL unit testing was perceived as time consuming and tedious. This tool is an attempt to get developers more focused on what to test rather than the correct syntax for the unit test code. I have not been able to use it extensively and still manually write unit tests but it may be worth investigating.


However, as with any framework/tool used, anyone using this it should still have a grasp of the theory behind unit testing otherwise it could result in badly tested code.

You should get a hold of an excellent book called Pragmatic Unit testing....
http://www.amazon.com/Pragmatic-Unit-Testing-Java-JUnit/dp/0974514012/ref=pd_bbs_sr_1/002-6962521-0874407?ie=UTF8&s=books&qid=1187015696&sr=1-1

it's used Java and JUnit for its examples but explains the theory of unit testing very clearly.

William Robertson

Posts: 6,456
Registered: 06/17/98
Re: Is testing really matter at PL/SQL
Posted: Aug 13, 2007 3:19 PM   in response to: Yawei Zhang in response to: Yawei Zhang
Click to report abuse...   Click to reply to this thread Reply
> ... they are introducing something called: testing, to make some test programms /utilites.

I found that is very hard to make, is it neccessary?

It's got to be better than the alternative, faith-based software development ;)
Hans Forbrich

Posts: 9,934
Registered: 03/13/99
Re: Is testing really matter at PL/SQL
Posted: Aug 13, 2007 11:18 PM   in response to: Yawei Zhang in response to: Yawei Zhang
Click to report abuse...   Click to reply to this thread Reply
I am reading a book: Learning Oracle PL/SQL by Bill
Pribyl and
Steven Feuerstein

I am a newbie of PL/SQL and I got no other
programming XPs. but in the very first of this book
they are introducing something called: testing, to
make some test programms /utilites.

I found that is very hard to make, is it neccessary?


Testing has one purposes - to verify that the program will do what is expected. (It is even harder to write the documentation describing what is expected.)

But without the documentation (specification) and the testing (verification) you may find out too late that the program occasionally does things wrong. While that may not matter much for a program that plays Solitaire, I suspect that it matters more when the program is responsible for calculating your paycheck or ensuring your mother gets the correct surgery.

Yes, testing is hard. Good and effective testing is one of the hardest and least respected areas of computing. Yet it is also, in my opinion, either the top or second most critical success factor in serious programming projects.

Testing should avoid most, if not all, that your program may enjoy.

ajallen

Posts: 1,162
Registered: 11/22/99
Re: Is testing really matter at PL/SQL
Posted: Aug 14, 2007 7:40 AM   in response to: Hans Forbrich in response to: Hans Forbrich
Click to report abuse...   Click to reply to this thread Reply
Testing has one purposes - to verify that the program will do what is expected. (It is even harder to write the documentation describing what is expected.)

I have to disagree with this. The purpose of testing is to cause the application/program/module/system/whatever to fail. To break it. To cause it to fall over. Anyone can prove that a program processes good clean data properly. What you want to know is
1. How will it handle improper data?
2. Does it handle boundary values correctly?
3. Does it handle all expected exceptions correctly?
4. Is there a fencepost error hidden in there some place?
5. What happens when an argument is missing?
6. Does it handle unexpected exceptions correctly?
7. How does increasing the load on the application by 100% affect performance?
8. How does increasing the load on the application by 10000% affect performance?
9. Have I tested all execution paths?
A. And on and on and on and on. . . .

Telling me that it handles correct data correctly is only part of the testing process -- the easy part. Now see if you can make the application fail.
JS1

Posts: 1,186
Registered: 06/22/07
Re: Is testing really matter at PL/SQL
Posted: Aug 14, 2007 7:45 AM   in response to: ajallen in response to: ajallen
Click to report abuse...   Click to reply to this thread Reply
Testing has one purposes - to verify that the
program will do what is expected. (It is even harder
to write the documentation describing what is
expected.)

I have to disagree with this. The purpose of testing
is to cause the
application/program/module/system/whatever to fail.
To break it. To cause it to fall over. Anyone can
prove that a program processes good clean data
properly. What you want to know is
. How will it handle improper data?
2. Does it handle boundary values correctly?
3. Does it handle all expected exceptions correctly?
4. Is there a fencepost error hidden in there some
place?
5. What happens when an argument is missing?
6. Does it handle unexpected exceptions correctly?
7. How does increasing the load on the application by
100% affect performance?
8. How does increasing the load on the application by
10000% affect performance?
9. Have I tested all execution paths?
A. And on and on and on and on. . . .

Telling me that it handles correct data correctly is
only part of the testing process -- the easy part.
Now see if you can make the application fail.


Where did Hans say that verifying that a program performs as expected did NOT take into account all of the points that you make, above. I certainly understood his text to mean that you test that the program would behave as expected both for perfect data and imperfect data and different conditions (as you have intiomated) and I certainly don't see where you picked up otherwise.
mlindsay

Posts: 38
Registered: 10/30/06
Re: Is testing really matter at PL/SQL
Posted: Aug 14, 2007 7:57 AM   in response to: ajallen in response to: ajallen
Click to report abuse...   Click to reply to this thread Reply
I agree with JS1, what Hans is saying is that the results of each test should match some sorts of specification document.

The points you make would be in such a document i.e. how should the unit of code perfom when boundray values are exceeded, how should exceptions be handled.

Good requirements allow a developer to write his unit tests before writing the body of his/her code. But such detailed requirements are not easy to produce.

I also wouldn't say that producing a test that proves the unit of code works under normal circumstances is any easier than testing the exceptions, the hard bit is defining what is 'correct'
Hans Forbrich

Posts: 9,934
Registered: 03/13/99
Re: Is testing really matter at PL/SQL
Posted: Aug 14, 2007 9:34 AM   in response to: ajallen in response to: ajallen
Click to report abuse...   Click to reply to this thread Reply
Testing has one purposes - to verify that the
program will do what is expected. (It is even harder
to write the documentation describing what is
expected.)

I have to disagree with this. The purpose of testing
is to cause the

Even though you seem to take issue, we are in agreement.

Note that I said " to verify that the program will do what is expected". Handling failures is part of my expectation.

A good specification also describes the failure handling. Good testing also verifies that the exceptional conditions are handled properly.

Anything less than handling exceptions is prototype code, good only for demos.

Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums