Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAPu3000Unit'su3000coverage

Former Member
0 Likes
731

Hi all

I had written a test code of abap, it is for test a form of abap pgm.

Now , I want to know the percent of coverage about this test code. How should I do.

For example:

This is my abap pgm.

FORM GET_LFG USING VALUE(L_AGE) TYPE N

CHANGING L_FLG TYPE N

IF L_AGE > 60.

L_FLG = 1.

ELSEIF L_AGE >= 40 AND L_AGE <= 60.

L_FLG = 2.

ELSE.

L_FLG = 3.

ENDIF.

ENDFORM.

This is my test code.

----


  • CLASS lcl_test DEFINITION

----


CLASS LCL_TEST DEFINITION FOR TESTING "#AU Duration Short

INHERITING FROM CL_AUNIT_ASSERT. "#AU Risk_Level Harmless

PRIVATE SECTION.

METHODS TEST_GET_LFG_SIMPLE_CALL FOR TESTING.

ENDCLASS. "lcl_test DEFINITION

----


  • CLASS lcl_test IMPLEMENTATION

----


CLASS LCL_TEST IMPLEMENTATION.

METHOD TEST_GET_LFG_SIMPLE_CALL.

  • Setup parameters for the call...

DATA :

L_AGE(2) TYPE N,

L_FLG TYPE N.

  • Perform the call

L_AGE = 61.

PERFORM GET_AGE USING L_AGE

CHANGING L_FLG.

  • Check returned values

ASSERT_EQUALS( ACT = L_FLG EXP = 1 MSG = 'ERROR FOR OVER 60 YEARS' ).

  • Perform the call

L_AGE = 55.

PERFORM GET_AGE USING L_AGE

CHANGING L_FLG.

  • Check returned values

ASSERT_EQUALS( ACT = L_FLG EXP = 2 MSG = 'ERROR FOR FORM 40 TO 60 YEARS' ).

ENDMETHOD. "TEST_GET_GLE_SIMPLE_CALL

ENDCLASS. "lcl_test IMPLEMENTATION

The test code just check two cases. the other case(<40) is not be tested.

thanks

ljz

Hi all

I had written a test code of abap, it is for test a form of abap pgm.

Now , I want to know the percent of coverage about this test code. How should I do.

For example:

This is my abap pgm.

FORM GET_LFG USING VALUE(L_AGE) TYPE N

CHANGING L_FLG TYPE N

IF L_AGE > 60.

L_FLG = 1.

ELSEIF L_AGE >= 40 AND L_AGE <= 60.

L_FLG = 2.

ELSE.

L_FLG = 3.

ENDIF.

ENDFORM.

This is my test code.

----


  • CLASS lcl_test DEFINITION

----


CLASS LCL_TEST DEFINITION FOR TESTING "#AU Duration Short

INHERITING FROM CL_AUNIT_ASSERT. "#AU Risk_Level Harmless

PRIVATE SECTION.

METHODS TEST_GET_LFG_SIMPLE_CALL FOR TESTING.

ENDCLASS. "lcl_test DEFINITION

----


  • CLASS lcl_test IMPLEMENTATION

----


CLASS LCL_TEST IMPLEMENTATION.

METHOD TEST_GET_LFG_SIMPLE_CALL.

  • Setup parameters for the call...

DATA :

L_AGE(2) TYPE N,

L_FLG TYPE N.

  • Perform the call

L_AGE = 61.

PERFORM GET_AGE USING L_AGE

CHANGING L_FLG.

  • Check returned values

ASSERT_EQUALS( ACT = L_FLG EXP = 1 MSG = 'ERROR FOR OVER 60 YEARS' ).

  • Perform the call

L_AGE = 55.

PERFORM GET_AGE USING L_AGE

CHANGING L_FLG.

  • Check returned values

ASSERT_EQUALS( ACT = L_FLG EXP = 2 MSG = 'ERROR FOR FORM 40 TO 60 YEARS' ).

ENDMETHOD. "TEST_GET_GLE_SIMPLE_CALL

ENDCLASS. "lcl_test IMPLEMENTATION

The test code just check two cases. the other case(<40) is not be tested.

thanks

ljz

6 REPLIES 6
Read only

Former Member
0 Likes
695

Anybody help me?

Read only

nomssi
Active Contributor
0 Likes
695

I have not used the tools yet, but you might want to try the runtime monitor (transaction SRTM) or the coverage analyser (transaction SCOV) for segment coverage.

best regards,

J. Nomssi N.

Read only

former_member183804
Active Contributor
0 Likes
695

Hello Lhz,

from netweaver release 7.02 onwards unit test execution with combined coverage measurement is integrated into the IDE (transaction SE80). For the older releases these are seperate tools. In case you are in your development system the follwoing approach may help.

Any code change to your report will also reset any coverage measurement (TA SCOV).

After a change execute your unit tests and review the effects in transaction SCOV. Please note that SCOV needs to be switch on explictely and that the so called data collection of SCOV happens not event based but on regular schedule. This can delay the arrival of your actions in the coverage results.

Kind Regards

Klaus

Read only

naimesh_patel
Active Contributor
0 Likes
695

As Klaus suggested, you can use the Coverage Analyzer to know the Coverage of your ABAP Unit Test.

Check this link:

http://help.sap.com/saphelp_nwpi71/helpdata/en/44/a7ed075c1a5e77e10000000a155369/frameset.htm

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
695

hi ,all

thanks your advices. I am having to use scov. If I got some result, I will share it.

Read only

0 Likes
695

We have been wondering the same thing at my company. SCOV gives us some data to start with but is generally a pain to set up and to focus on a specific piece of code that we are currently developing.

I have read that 7.02 will have some more robust features as it pertains to code coverage and we look forward to that. If anyone else has another way to calculate code coverage based on unit testing I would appreciate any information you can provide.

Andy