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

ABAP unit tests will not run

Former Member
0 Likes
2,346

I'm facing a situation where my ABAP unit tests won't run. The system displays the success message

Processed successfully: 1 programs, 0 test classes, 0 test methods

Message no. SABP_UNIT110

In practice, no test methods were executed.

The issue is somehow tied to the fact that our company uses a specific /COMPANY/ namespace. I verified this by creating the exact same two classes, methods and unit tests, with the only difference that one class is ZCL_AU_TEST and the other is /COMPANY/CL_AU_TEST. Same risk levels, durations and all. They are in the same system. The ZCL class runs the tests as it should, but the /COMPANY/CL class just won't run.

I'll include the coding of those simplistic classes below.

I've generated the local test class and methods with the wizard. We've also set the profile parameter abap/test_generation to on, just to make sure it won't prevent the unit tests from compiling.

The test's assert_equals call should fail. Yet, 0 test methods processed. Why?

class /COMPANY/CL_AU_TEST definition

  public

  final

  create public .

public section.

  class-methods CALCULATE_PERCENTAGE

    importing

      !I_FLOAT type F

    exporting

      !E_FLOAT type F .

protected section.

private section.

ENDCLASS.

CLASS /COMPANY/CL_AU_TEST IMPLEMENTATION.

* <SIGNATURE>---------------------------------------------------------------------------------------+

* | Static Public Method /COMPANY/CL_AU_TEST=>CALCULATE_PERCENTAGE

* +-------------------------------------------------------------------------------------------------+

* | [--->] I_FLOAT                        TYPE        F

* | [<---] E_FLOAT                        TYPE        F

* +--------------------------------------------------------------------------------------</SIGNATURE>

method CALCULATE_PERCENTAGE.

    e_float = i_float * '0.9'.

endmethod.

ENDCLASS.

class zcl_Test definition for testing

  duration short

  risk level harmless

.

*?<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">

*?<asx:values>

*?<TESTCLASS_OPTIONS>

*?<TEST_CLASS>zcl_Test

*?</TEST_CLASS>

*?<TEST_MEMBER>f_Cut

*?</TEST_MEMBER>

*?<OBJECT_UNDER_TEST>/COMPANY/CL_AU_TEST

*?</OBJECT_UNDER_TEST>

*?<OBJECT_IS_LOCAL/>

*?<GENERATE_FIXTURE>X

*?</GENERATE_FIXTURE>

*?<GENERATE_CLASS_FIXTURE/>

*?<GENERATE_INVOCATION>X

*?</GENERATE_INVOCATION>

*?<GENERATE_ASSERT_EQUAL>X

*?</GENERATE_ASSERT_EQUAL>

*?</TESTCLASS_OPTIONS>

*?</asx:values>

*?</asx:abap>

  private section.

* ================

    data:

      f_Cut type ref to /COMPANY/cl_Au_Test.  "class under test

    methods: setup.

    methods: teardown.

    methods: calculate_Percentage for testing.

endclass.       "zcl_Test

class zcl_Test implementation.

* ==============================

  method setup.

* =============

    create object f_Cut.

  endmethod.       "setup

  method teardown.

* ================

  endmethod.       "teardown

  method calculate_Percentage.

* ============================

    data i_Float type f.

    data e_Float type f.

    i_float = 1.

    /COMPANY/cl_Au_Test=>calculate_Percentage(

      EXPORTING

        I_FLOAT = i_Float

     IMPORTING

       E_FLOAT = e_Float

    ).

    cl_Abap_Unit_Assert=>assert_Equals(

      act   = e_Float

      exp   = '0.8' "obvious error!

    " msg   = 'Testing value e_Float'

*     level =

    ).

  endmethod.       "calculate_Percentage

endclass.       "zcl_Test

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,625

OK, got this sorted out through testing and comparing with other systems.

The unit tests will compile and run, once the namespace is registered (in SE03) with a development license and in a Producer role.

2 REPLIES 2
Read only

Former Member
0 Likes
1,625

hi

Where you put above code? if it's in function, so above code should put at before 'ENDFUNCTION'.

regards,

Archer

Read only

Former Member
0 Likes
1,626

OK, got this sorted out through testing and comparing with other systems.

The unit tests will compile and run, once the namespace is registered (in SE03) with a development license and in a Producer role.