Skip to Content
0

ABAP Unit Test Wizard Local class not showing

Nov 29, 2017 at 10:50 AM

87

avatar image
Former Member

Hello All,

Could you please kindly help me with understanding how to solve issue?

I have created sample class via se24 . All activated with no issues. When I try to create via wizard Unit test class with option Local class field "Local Class Name" is empty and wizard doesn't let me go further. I as well tried to create local test class in include for local test classes, activated it but when again run wizard still when I choose "Local Class Name" - drop down list is still empty.

Best Regards,

Maria.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Horst Keller
Dec 04, 2017 at 04:15 PM
2

As Mike already said, forget the wizard, you don't need it. Some years ago, there was a kind of wizardmania, but it seems that in some situations they hinder more than help. In fact, I even didn't know or I forgot about that one.

Simply code your test class(es) by hand in the test include. Simple and straightforward.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hello Horst,

Thanks for help. With wizard I wanted to see difference between local and global test classes. Due to when I used wizard for global test classes creation it created it as local:) my understanding of Global test classes we use it as services Global test classes visible in se24 and have class category = 5 (Test Classes) . Do I understand correctly ?

BR,

Maria.

0

From the documentation:

A test class is usually a local class. Global test classes (visible in se24 ) can be created for reusing complex test preparations. Global test classes should always be abstract and can only be used in local test classes. Currently, all instance methods of a global test class are automatically test methods.

So you understand correctly.

Also for a global test class, do it directly. Create it in SE24, you don't need the wizard. A local test class can then inherit from the global test class.

3
Suhas Saha
Nov 29, 2017 at 11:05 AM
1

If i understand correctly you are trying to fill in the name of the "Local class" of the global class.

You should just select the option "Global class" and click continue.

In the next step, you'll get the option of either selecting an existing test class(from the dropdown list) or creating a new one.

BR,

Suhas

PS - I would recommend you to switch to Eclipse (ADT), if possible. In ADT you can use a template which will generate the Test Class for you. Much easier!


Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hello Suhas,

With global classed I tried all working fine. However my task is to work with local test classes.

I am trying to understand why wizard not showing local test classes for drop down.

I have created local class in include via click on Local Test Class. In official SAP documentation it is has been written we can call WIZARD anytime to add fixtures etc. So on screen 2 you see sample code for empty local unit test class which I wrote. However when I call wizard see last pic and choose local class my drop down is empty I was expecting it will catch up name from local test class include. Do I do anything wrong please kind advice.

w1.jpg (128.6 kB)
w2.jpg (136.8 kB)
0

However when I call wizard see last pic and choose local class my drop down is empty

I think you missed the screenshot!

1
Mike Pokraka Nov 29, 2017 at 11:22 AM
1

It's asking you what class you want to test. As you don't have any local classes this is empty. If you have other local classes they will appear here.

Select global class to generate a test class for your ZCL... global class. You define the test class details in the following steps.

Show 5 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hello Mike,

Thing is I have created local test class in include (please see my answer with pics to Suhas ), however when I am calling wizard drop down list still empty when I choose local class option.

Please kindly advice.

BR, Maria.

0

I'm guessing, but maybe it doesn't recognize your own-written class. I suggest deleting the class and trying again (make a backup copy if you have real code). Even though this dropdown looks identical to the other one, you can type a class name in there, it will generate the class for you.

As an aside, personally I haven't used the wizard for a long time. The code you wrote looks fine, and I prefer to write test methods according the test being performed, rather than as the wizard generates it (one test method per class method).

2
Former Member

Issues is not with my class with colleagues classes too and on various SAP systems.

0

Don't confuse local classes and local test classes. In the wizard screen, the local class mentioned is not a local test class!

A class pool contains by default only one class which is named the global class (same name as the class pool). A local class is an additional class that may be used only from the global class (or by another local class of the same class pool).

So, if you don't have any local class (I'm not talking of a local test class), do as Suhas suggested, create a local test class to test the global class.

0

It sounds like you're still missing the point. The first dialog is asking you what to test. The "Local Class" option in the dialog from the screenshot is to test a local class, not to generate it.

Let's say you have a class ZCL_HELLO. In this class you create a local class LCL_TEXT_HELPER because your language logic is a bit complex.

Now the class selection wizard should show you the LCL_TEXT_HELPER as a "Local Class" choice, because you could test the global class ZCL_HELLO or the local class LCL_TEXT_HELPER.

3