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

Unit Testing concept

Former Member
0 Likes
845

Hi,

I want to test some 10 scenario,In Every scenario 1 table is expect and 1 get for actual .

For that i want to use for every scenario the class below,

Something that i miss what happen if there is problem in table1 and in table2 the program continue and display the both problems or it exit and bring just the problem in table1.

if so there is a way to bring all the tables errors?

Regards

cl_aunit_assert=>assert_equals( exp = <table1> quit = cl_aunit_assert=>no act = table1  msg = msg ).
cl_aunit_assert=>assert_equals( exp = <table2> quit = cl_aunit_assert=>no act = table2  msg = msg ).

And so on....

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
674

Parameter QUIT of the ASSERT_EQUALS will determine what to do after you got assertion in the CL_AUNIT_ASSERT=>ASSERT_EQUALS method.

In this below example, test execution will contine even if assertion would be raised by the first call because we have specified CL_AUNIT_ASSERT=>NO. But it will terminate the method if the second call fails because we haven't specified any this thing.


METHOD TEST_1.
...
CL_AUNIT_ASSERT=>ASSERT_EQUALS(
         ACT = <a_tab1>
         EXP = <e_tab1>
         QUIT = CL_AUNIT_ASSERT=>NO  " <<
         MSG = 'Main data not matching').

CL_AUNIT_ASSERT=>ASSERT_EQUALS(
         ACT = <a_tab2>
         EXP = <e_tab2>
         MSG = 'Main data not matching').

CL_AUNIT_ASSERT=>ASSERT_EQUALS(
         ACT = <a_tab3>
         EXP = <e_tab3>
         QUIT = CL_AUNIT_ASSERT=>NO
         MSG = 'Main data not matching').

ENDMETHOD.

Now, you should set the value of the parameter QUIT if you want to stop:

Current test Method use CL_AUNIT_ASSERT=>METHOD

Current test Class use CL_AUNIT_ASSERT=>CLASS

Current program use CL_AUNIT_ASSERT=>PROGRAM

Regards,

Naimesh Patel

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
675

Parameter QUIT of the ASSERT_EQUALS will determine what to do after you got assertion in the CL_AUNIT_ASSERT=>ASSERT_EQUALS method.

In this below example, test execution will contine even if assertion would be raised by the first call because we have specified CL_AUNIT_ASSERT=>NO. But it will terminate the method if the second call fails because we haven't specified any this thing.


METHOD TEST_1.
...
CL_AUNIT_ASSERT=>ASSERT_EQUALS(
         ACT = <a_tab1>
         EXP = <e_tab1>
         QUIT = CL_AUNIT_ASSERT=>NO  " <<
         MSG = 'Main data not matching').

CL_AUNIT_ASSERT=>ASSERT_EQUALS(
         ACT = <a_tab2>
         EXP = <e_tab2>
         MSG = 'Main data not matching').

CL_AUNIT_ASSERT=>ASSERT_EQUALS(
         ACT = <a_tab3>
         EXP = <e_tab3>
         QUIT = CL_AUNIT_ASSERT=>NO
         MSG = 'Main data not matching').

ENDMETHOD.

Now, you should set the value of the parameter QUIT if you want to stop:

Current test Method use CL_AUNIT_ASSERT=>METHOD

Current test Class use CL_AUNIT_ASSERT=>CLASS

Current program use CL_AUNIT_ASSERT=>PROGRAM

Regards,

Naimesh Patel

Read only

0 Likes
674

Hi Naimesh ,

You can elaborate on this please,

I don't sure if i understand it ,example will help.

Current test Method use CL_AUNIT_ASSERT=>METHOD
Current test Class use CL_AUNIT_ASSERT=>CLASS
Current program use CL_AUNIT_ASSERT=>PROGRAM

Thanks in advance .

Read only

0 Likes
674

These values for the parameter QUIT will determine the execution of the next test method, test class or entire program in case of the failure.

When you use QUIT = CL_AUNIT_ASSERT=>METHOD, ABAP Unit farmework will not execute any test method in the same test class if this assertion fails.

When you use QUIT = CL_AUNIT_ASSERT=>CLASS, ABAP Unit farmework will exit from current test class if this assertion fails.

I would suggest to go through this TechEd session:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/395c5770-0701-0010-039b-f3ef11ac55...

Look for the section "Test Sequence of Failed Tests"

Regards,

Naimesh Patel