10-19-2012 3:32 AM
Dear Mentors!
I have been hunting to find a a good start with SAP Unit.
What ever I find, on wiki or on google shows, say, how to test 2+2 or 3*5. I don't find any post showing how to use it, say abap report, where it is not so easy to determine the expected result. All the data is fetched form database, How do i test it?
I am really hopeful that someone will come forward with help!
Thanks in advance!
10-25-2012 3:38 PM
In order to use ABAP Unit effectively, you need to write your program from the start in a style that makes it possible to Unit Test. For the database issue specifically, look up dependency injection (you can google it i'm sure). In short, it's a way to define all your test data in the unit test, and for the unit test only use this test data instead of selecting against the database. Here's an ABAP-specific blog post on dependency injection:
There's a term for the larger concept of developing your program in such a way. It's called Test-Driven Development. You can google that term and find a bunch of information. Here's a link to get you started (but it's a big topic, so I suggest spending some type surfing the web):
http://www.g3it.com/blog/technical/abap/adopting-test-driven-development-using-abap-unit/
10-25-2012 3:57 PM