Application Development 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: 

UNIT CLASS FOR TESTING

Former Member
0 Kudos

Hello Experts ,

In se24 I am creating the class for tesing BUT when I try to test byclicking on UNIT TEST .

It gives message :-

NO EXECUTION AS ACTUAL RISCK LEVEL IS TOO HIGH

CAN U HELP ME IN SOLVING THIS PROBLEM ?

-


class's PUBLIC SECTION IS AS FOLLOW .

class ZUNITTESTCLASS98 definition

public

  • final

create public

for testing "#AU Risk_Level HARMLESS

.

" public components of class ZUNITTESTCLASS98

" do not include other source files here!!!

public section.

-


PRIVATE SECTION

private section.

methods CHECK_REFERNCE

for testing .

-


CODE FOR THE METHOD :-

method CHECK_REFERNCE.

DATA OBJ1 TYPE REF TO ZWDCSOPERATION98 .

CREATE OBJECT OBJ1.

FIELD-SYMBOLS <TAB1> TYPE STANDARD TABLE .

DATA REF1 TYPE REF TO DATA .

CALL METHOD OBJ1->GET_TABLE

EXPORTING

TAB_NAME = 'SFLIGHT'

RECEIVING

R_TABLE = REF1

.

CALL METHOD CL_AUNIT_ASSERT=>ASSERT_BOUND

EXPORTING

ACT = REF1

MSG = 'REFERENCE IS NOT POINTING TO ANYVALID DATA '

  • LEVEL = CRITICAL

  • QUIT = METHOD

  • RECEIVING

  • ASSERTION_FAILED =

.

endmethod.

-


1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

While using the class builder, try not to change the definition manually. You can set the Risk Level, to Harmless in the Properties tab. Since this #AU is the pseudo comment, it must be like "Harmless", not HARMLESS.


class ZCL_TEST_NP_TEST definition
  public
  abstract
  create public
  for testing
  "#AU Risk_Level Harmless
.

You would not be able to perform the Unit test (from menu Program > Unit Test) on this test class. You need to create a local test class inheriting from this global test class in the production class (class on which you want to perform the test). Please refer to these discussions:

Regards,

Naimesh Patel

3 REPLIES 3

naimesh_patel
Active Contributor
0 Kudos

While using the class builder, try not to change the definition manually. You can set the Risk Level, to Harmless in the Properties tab. Since this #AU is the pseudo comment, it must be like "Harmless", not HARMLESS.


class ZCL_TEST_NP_TEST definition
  public
  abstract
  create public
  for testing
  "#AU Risk_Level Harmless
.

You would not be able to perform the Unit test (from menu Program > Unit Test) on this test class. You need to create a local test class inheriting from this global test class in the production class (class on which you want to perform the test). Please refer to these discussions:

Regards,

Naimesh Patel

Former Member
0 Kudos

THIS QUESTION IS RESOLVED

0 Kudos

Hi Rushi,

I am new to oops concept but i am able to understand.

Now i have to create some Unit test plans in ABAP.We are using SAP Netwever 7.1 and WEB AS 6.0

I tried from SE24 but i couldn't get the correct path.

Can you please explain me: if i have a Z program then where and how to write a number of Unit test classes. And how it will integrate to with our actual program/FM/any object

Thanks

Umashankar.