Saturday, March 21, 2009

Test Driven Development for PeopleSoft

The PeopleTools blogging team just released an unsupported tool for test driven PeopleCode development: PSUnit. The blog post contains the PSUnit source code and a document that describes how to use PSUnit to test drive PeopleCode development. If you are familiar with one of the xUnit frameworks (jUnit, nUnit, utPLSQL, Test::Unit, etc) and eXtreme Programming, then you know the value of test driven development. If you are new to Test Driven Development (TDD), then take a look at Kent Beck's book Test Driven Development by Example.

As a fellow PeopleCode programmer, I believe we can create better solutions by applying proven disciplines and methodologies to PeopleCode development.

11 comments:

Dan said...
This comment has been removed by the author.
Dan said...

Hi Jim

Thanks for your work on psunit. I've been hearing about it for some time and gave it a spin last night. It seems to work great.

However the word doc "Introducing PSUnit" has a number of problems including never mentioning the database table. Of course the test turned up that problem. But, in fact, I never did get the logger test to pass. Seems to not commit the flag to the database. Perhaps it should be made into a wiki so others can chip in their corrections.

Jim Marion said...

@Dan, I can't take credit for creating PSUnit. I can, however, take full responsibility for the 15 page Word document.

By, "never mentioning the database table," do you mean the ADS_LOG_CONFIG table? You are correct in saying that I didn't spend much time with that. I actually describe it at the top of page 13, "From the Run method, you can see that I chose to store the on/off configuration flag in a one row table named ADS_LOG_CONFIG with one field named FLAG." Perhaps I should have shown a screenshot of the table, but I really didn't want to spend any time on that piece.

Now, about the Y/N flag, I believe I had to SQL insert that the first time so it was there to update. Otherwise, the updates in the test succeed, but don't do anything. If you don't SQL insert it, then it won't exist. It appears that I forgot to put that SQL in the doc. I am very sorry.

You are right, this should be a wiki. It should be in a wiki attached to an open source project built off this piece of code. I will see if I can get it moved to The Official Oracle Wiki. I know PeopleTools product strategy has other pages on the wiki.

Please send me more feedback including letting me know if an SQL insert of the on/off flag resolves the issue.

Jim Marion said...

@Dan, you are so right about not getting that last TestLogger test to pass. Here is the SQL to run prior to running that test. I should have inserted this into the top of page, just above the text "Run the test again to see success..."

INSERT INTO PS_ADS_LOG_CONFIG VALUES('N')
/
COMMIT
/

Please let me know if you find any other issues! Thanks again Dan!

Dan said...

Now it passes!

Yes, in rushing thru the setup I missed the table step. Adding the initial record was the key to final success.

Another problem I had was the order in which the ADS_LOGGER classes are added. I think you should add and save Target interface before Logger. I had problems saving doing it the other way around.

It would be great to see other examples of how PSUnit is used, especially testing components - I'm imagining using a CI.

Thanks
Dan

Jim Marion said...

@Dan, it is now on a wiki: Introducing PSUnit on Oracle Wiki.

I added the missing SQL and your recommended clarifications (order of creating objects, building records, etc).

Dale Johnson said...

Jim,

With a job like yours, you really need a backyard farm to relax in.

Dale Johnson

kane81 said...

Doh! I created my own unit framework already earlier this year! Grrr!

guess it wont be too hard to wrap the new framework so my existing testers will work with the nice tester.

My tester was a text area where you put your test class/test suite name into, then press run to see the results in another test area.

Amit said...

Hi jim,

I would like to use psunit. Could you please help me to get it.

Jim Marion said...

@Amit, I don't have access to it anymore. You might post a question in the PeopleSoft OTN General Discussion forum to see if anyone else has access.

Amit said...

Thanks jim, i will try to get there. Lets be positive.