Code Inspector & ABAP UNIT Testclasses

Hallo all,
I am currently trying to implement automated checks using the code inspector. I especially want to see if all our developers use our naming conventions. Also, we use ABAP Unit tests. Unfortunately, the generated test classes are not compliant with our name conventions (And also these Test classes are not interesting to be checked).
Now, I receive many warnings, mostly from the Unit test implementations.
Now: Is there a way to exclude these local test classes from my object set?
Thanks for you help!
Best regards,
Martin Imme

Other language NUnit test frameworks similar to ABAP Unit (AUnit) commonly have project extensions for storing test results. These are useful for the unit level regression (did a new change break any existing functions). History of test results, help narrow down the nature of a current failure by answering the question of 'When did this break?' or when did it last pass? In systems dependent upon outside components the history can provide a pattern for occasional failures due to factors outside the system under test.
I see that ABAP unit test results can be added into the Code Inspector under the Check Variant.
1. Is it common or recomended to use the Code Inspector (SCI) to store AUnit test results?
2. Is it common or recomended to use Code Inspector Object variants to collect individual AUnit tests for a regresssion style 'TestSuite'?
3. What reporting or tools exists for Code Inspector history?
4. Is Application Logging the better spot for AUnit results history?
(also posted on the wiki.. apologies - I'm new to the forum and wiki)
Will Loew-Blosser

Similar Messages

  • Execute ABAP Code Inspector from Outside of SAP

    Hi all...
    For reporting purpose, I would like to use ABAP Code Inspector (transaction SCI) for generating output as a file, it should call from outside of SAP through RFC function module and generate the list (output) as flat file (or XML), does anyone have been done with similar work like this? I wonder if you could share your experience with me...
    thanks in advance,
    yayan irianto.

    I managed to set up the variant, however found a problem.
    I used "Search ABAP Statement Patterns" under "Search Functs" and set the pattern like followings.
    SELECT + INTO *
    SELECT SINGLE + INTO *
    However following statements were detected.
    SELECT * INTO TABLE IT_DRAW FROM DRAW.
    SELECT MANDT INTO TABLE IT_DRAW FROM DRAW.
    SELECT SINGLE * INTO TABLE IT_DRAW FROM DRAW.
    SELECT SINGLE MANDT INTO TABLE IT_DRAW FROM DRAW.
    It's because + means one ABAP token in the code inspector.
    Is there anyway to find only "SELECT SINGLE *" and "SELECT *" ?

  • Abap code inspector (tx : SCI) to detect certain patterns

    Hello Experts,
    I want to use SAP Code Inspector to detect common problematic ABAP codes for all developed programs.
    But, I don't know how to make the check variant for detecting follwoing three patterns.
    SELECT * FROM
    SELECT * INTO
    SELECT SINGLE * INTO
    I guess I can use "Search for ABAP tokens" or "Search for ABAP statements paterns". But, It did'nt work because ' * ' represents any sequence of characters in the code inspector.
    Anyone can help me?

    I managed to set up the variant, however found a problem.
    I used "Search ABAP Statement Patterns" under "Search Functs" and set the pattern like followings.
    SELECT + INTO *
    SELECT SINGLE + INTO *
    However following statements were detected.
    SELECT * INTO TABLE IT_DRAW FROM DRAW.
    SELECT MANDT INTO TABLE IT_DRAW FROM DRAW.
    SELECT SINGLE * INTO TABLE IT_DRAW FROM DRAW.
    SELECT SINGLE MANDT INTO TABLE IT_DRAW FROM DRAW.
    It's because + means one ABAP token in the code inspector.
    Is there anyway to find only "SELECT SINGLE *" and "SELECT *" ?

  • ABAP unit: test classes part of prod. code

    Hi all,
    I've read <a href="https://weblogs.sdn.sap.com/pub/u/266">Thomas Weiss</a>'s weblog: <a href="/people/thomas.weiss/blog/2004/12/17/a-spotlight-on-abap-unit-part-1 Spotlight on ABAP Unit Part 1</a>.
    I posted a question there, but apparently Thomas can't answer at the moment, and since I'm impatient for getting someone's opinion, I reckon we can discuss that topic here  :^)
    As explained in the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1be1003-0701-0010-3795-f87160de6483">NetWeaver Developer’s Guide Using ABAP</a>, the test classes are part of the program under test (PUT):
    <i>In ABAP Unit, test classes are part of the production code of the TU. This avoids problems arising from the test code being separate from the production code:
    - Programs and tests must be kept synchronized.
    - You have to ensure that the test and program code are transported together.
    - External test code only enables black box tests with an outside perspective of the tested program.
    Since the test code is part of the production code, it is easy to keep the unit tests and the
    production code up to date if the latter is changed.
    Although the test code and the production code are transported through the system landscape, ABAP unit tests do not increase the load on the production system. By default, the test code is not compiled in the production system. Therefore, the test code can never be executed in the production system.</i>
    On the other hand, this idea is quite different from what suggested by other unit testing frameworks.
    For instance, the documentation of <a href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html">Test::Unit - Ruby Unit Testing Framework</a> reads:
    <i>It‘s handy to collect a bunch of related tests, each test represented by a method, into a common test class that knows how to run them.
    The tests will be in a separate class from the code they‘re testing for a couple of reasons. First of all, it allows your code to stay uncluttered with test code, making it easier to maintain. Second, it allows the tests to be stripped out for deployment, since they‘re really there for you, the developer, and your users don‘t need them. Third, and most importantly, it allows you to set up a common test fixture for your tests to run against.</i>
    Regarding the advantages outlined by NetWeaver Developer’s Guide:
    - Programs and tests might be kept synchronized even if they don't belong to the same unit of code.
    - Moreover, you could assure that the test and program code are transported together by saving them in the same package.
    - And quite frankly, I don't have a thourough understanding of the reason why external tests only allow <i>black box tests with an outside perspective</i>.
    What are your opinions on this?
    Regards, Davide

    Hi,
    when I started unit testing with JUnit I was quite surprised that SAP groups the tests with the production code. But now I actually really like it. It has a few advantages:
    - Good tests serve as an excellent documentation so why not bundling them together.
    - If you want to look at the tests they are easy to find.
    - I write all my class tests as local classes. I found out that it really helps me to focus on writing tests only for the class under test. Sometimes it is quite easy to forget the "unit" and write integration tests again.
    Regarding your question:
    >And quite frankly, I don't have a thourough understanding of the reason why external tests only allow black box tests with an outside perspective.
    Usually I would not use the term black box testing in this context. Maybe you mean that it is easy to access private attributes, methods when you group class and testclass together?
    Normally black box testing means that you cannot look at the implementation of the code under test. So your tests are based on the specifications or if there is not one, on your common sense.
    cheers
    Thomas

  • ABAP Code Inspector & Security

    All:
    I am currently looking into the Code Inspector that is built into SAP that allows developers to run test/checks on their code related to performance, syntax, and as noted "security". I am trying to track down what exactly the "security" is being checked. I am running tests on my internal SAP systems to see how it acts, but I wanted to get any feedback from the security community on a few things
    1) What "security" checks does the Code Inspector actual check for?
    2) Is there an location with updated documentation from SAP (not dated 2002) which speaks to the security componet, not just mentioned it?
    3) Any useful use-cases within the security community that your organization/clients are using?
    Thanks,
    Matt Urban

    Hi,
    if you display a check variant in SCI there is info linked to each node (icon with I). For example calling C-routine is a security risk. Also dynamic statements are good example of security risk. You need to validate input properly before executing dynamic statement. Not sure about documentation but documentation available in SCI seems OK to me.
    On one project we used SCI to check any custom development (not only security). It helped us to increase quality of custom development. Especially, with less skilled developers.
    Cheers

  • ABAP Code Inspector

    Is there a way to confine the checks performed by Code Inspector to my
    program only?
    My program invokes much SAP-supplied code in the form of includes.  And
    the code inspector covers this code as well.  I am interested in seeing the
    results for my code only.

    Hello Gregory,
    Using the INCLUDE statement makes any coding part of the program for the compiler and most checks within the Code Inspector.
    Best Pratice is not to use/offer INCLUDES for reuse. If fury old code makes the inclusion mandatory then wrapping it in a resuse component. e.g. a function group is the next best solution.
    Best Regards
      Klaus

  • Two Questions on ABAP UNIT

    I'm familiar with the technical concept of ABAP Unit testing, using both local or global classes, running sets of Unit Tests using the Code Inspector. However, I'm struggling with two issues:
    a) Technical issue: how can I test a Protected or Private method of a class using ABAP Unit testing? It works if the class to be tested has granted friendship to the unit test class, but is that the way to do this?
    b) conceptual issue on the types of Unit Tests to define: the Unit Test is based on comparing actual results with expected results. But how can I predict a result on a development environment that is constantly changing?
    Thanx in advance
    Ben Meijs

    Hi!
    For having plan vs actual report, first of all you need to define CO versions through ORKE for your operating concern. You also needs to define plan version through KE14. Also you need to assign COPA reciever plan version for integrated planning.
         All your SD condition types need to be assigned to value fields. Also to flow actual values of production orders, CO Orders - it is required to assign PA transfer structure to settlement profile. Settlement profile must allow profitlability segments as settlement recievers and it must be stored in settlement profile. The assignment ensures that variances also flows to COPA. Key figure should also be defined for when assessment is caried out from cost center accounting to COPA. Also your value fields are also to be assigned to Cost component structure in COPA.
           After doing above necessary activity, you may plan for your form of report through KE34. Lines, form and header are specified by means of characteristics or value fields.
    Hope it helps a lot!
    Please revert back for any query.
    Thanks & Regards,
    Taral Patel

  • Differences between SLIN and Code Inspector

    Hi,
    Can anyone tell me the differences between SLIN and Code Inspector(SCI)..?
    and in which cases we use SLIN and  SCI..?
    and as an ABAPer, which one should we prefer..?
    Thanks,
    Pradeep.

    Hi
    Extended syntax check or SLIN is used to check the program in all aspects for the different syntaxes like
    When you use select single whether you have passed all the key fields or not>
    whether you have maintained the text elements texts or not,
    Have you used UNIT...CURRENCY along with the QTY and AMOUNT fields when displayed using the WRITE statement
    and check for all the varities of statements used in the code, and if there is some problem with that statement/command, it will display as error or warning.
    Check following links -
    slin
    can any one tell me abt SLIN T-CODE
    Reward points if useful
    Regards
    Anji

  • ABAP Unite : how to get the generated log

    Hi all,
    I'm looking for a way to get the log of the execution of a program linked abap unit tests.
    Imagine that I'm using se38 transaction, I launch Program >> test >> Unit Test.
    It give me a result screen with the result of defined assert.
    What I need is a way to do my own program that can access to this result in order to export them to a specific extarnal test management tool.
    So, I would like  to know the transaction code of the abap unit transation, the table filled by the log and so on ...
    Thanks  for help,
    Kind Regards
    Morgan

    Hello Morgan,
    there is no API to access ABAP Unit results in release 6.40 und 7.00. You will have to wait for 7.10.
    Sorry
      Klaus
    PS: You may try to access Code Inspector Results meanwhile.

  • Code Inspector/ATC checks for VKOS/VKOI object types

    Dear Experts,
    I found a strange behavior while executing CI checks on a transport request. TR contained only IMG Activity objects (Object Type VKOS/VKOI). After CI checks it gave errors "Recognized dead code". There is no coding for these kind of object type, I don't know where it was able to find the dead code. On debugging I found that, it is trying to populate Program name concatenatinv " SAPIC " and the object type. ( SAPICVKO). But there is no such program existing. It then gives "Recognized dead code" error.
    Has anyone faced such error before? I guess this is error in the standard program.
    Thank you.

    Other language NUnit test frameworks similar to ABAP Unit (AUnit) commonly have project extensions for storing test results. These are useful for the unit level regression (did a new change break any existing functions). History of test results, help narrow down the nature of a current failure by answering the question of 'When did this break?' or when did it last pass? In systems dependent upon outside components the history can provide a pattern for occasional failures due to factors outside the system under test.
    I see that ABAP unit test results can be added into the Code Inspector under the Check Variant.
    1. Is it common or recomended to use the Code Inspector (SCI) to store AUnit test results?
    2. Is it common or recomended to use Code Inspector Object variants to collect individual AUnit tests for a regresssion style 'TestSuite'?
    3. What reporting or tools exists for Code Inspector history?
    4. Is Application Logging the better spot for AUnit results history?
    (also posted on the wiki.. apologies - I'm new to the forum and wiki)
    Will Loew-Blosser

  • Integrating Code Inspector with Continious Integration Tools

    Hi everybody,
    outside the ABAP-world there is a large number of tools available, both commercial and open source, that support the continuous integration within software projects. One part of theses tools it to execute any available unit test after each commit to the source code. The code inspector (SCI) within SE80 basically can do something very similar. Run unit tests, check for coding conventions etc.
    I was wondering if the is a simple way to integrate the code inspector with existing tool, SAP external, continuous integration tools. I envision something like that after each transport or once per day SCI is executed and the results are made available in the external tool.
    Has anyone here ever done something like that? Are there any existing solutions available for it of the shelf?
    Thanks,
    Christian

    Hi
    please check the blog
    [/people/christian.drumm/blog/2009/12/30/continuous-integration-using-code-inspector|/people/christian.drumm/blog/2009/12/30/continuous-integration-using-code-inspector]
    and the discussion on the treads,
    [Is it possible to integrate the Code Inspector in Transport Management|Is it possible to integrate the Code Inspector in Transport Management]
    might be this helps
    Thanks,
    Jansi

  • ABAP Unit Test Problem

    Here we go again on questions regarding ABAPUnit.  We are trying to use Abap unit within a Class object.  All the examples we have seen have to do with Classes and Methods within a Report program. 
    What we have created:
    Class: ZCL_MAIN
    Type: General Class
    Method:  test_abapunit
    Class: ZCL_MAIN_TEST
    Class type: Abap Unit
    Sub Class of ZCL_MAIN
    Method: Test_abapunit_test 
    We try and run the Abap Unit Test from the Test Class and it says it is complete but does not execute our code.  I know we are doing something wrong but are stumped as to what it is.
    Glenn

    Hi Glenn,
    although Uwe and Klaus actually provided for the relevant information we too faced some difficulties at first understanding 'where' you actually put the test classes. So here are the mechanics:
    Open SE80 or SE24 and implement your class ZCL_MAIN.
    While this class is opened, choose <i>Goto->Class-local types->Local Class Definitions/Types</i> from the menu. An editor for local classes is opened on the right.
    Type in your class definition ZCL_MAIN_TEST like this:
    CLASS lcl_main_test DEFINITION FOR TESTING.
      "#AU Risk_Level Harmless
      PRIVATE SECTION.
        CONSTANTS: some_initial_test_value TYPE i VALUE 5.
        DATA: main_class TYPE REF TO zcl_main.
        METHODS setup     FOR TESTING.
        METHODS teardown  FOR TESTING.
        METHODS check_get_my_int FOR TESTING.
        METHODS check_.. FOR TESTING.
    ENDCLASS.
    This is btw a 'normal' local class, no subclass of cl_abap_unit.. whatsoever.
    Go back (menu <i>Goto->Class Definition</i>).
    Choose <i>Goto->Class-local types->local class implementations</i> from the menu.
    Type in your class implementation for ZCL_MAIN_TEST, i.e. implement especially the setup()-method for the test fixture and the various test-methods.
    Compile/activate your class ZCL_MAIN.
    Run the test by choosing <i>Test->Unit Test</i> from the context menu of the class ZCL_MAIN.
    Hope this helps, regards,
    Sebastian

  • How to remove Unicode errors from extended check and code inspector

    Hi
    We are working on making all our ABAP program to make unicode compliant. We are activating unicode flag in attribute and correcting syntax errors. After this when we do the extended checks or SLIN or code inspector, usually giving error for many statements such as whenever there is message.
    <b>Code is :</b>message a208 with text-004.
    <b>Error description is</b> :
    The message 208 for id zz has no long text.
    You can hide this message using "#EC *
    208 is -   & does not exist in & &. And  text 004 is - Cannot open the output file
    By using #EC * we can remove errors. But Is this the correct way and what does this indicate? Please explain.

    Hi Yogesh,
    Can you check whether the message number 208 in message id ZZ has the Self Explanatory checkbox as checked or not? I think it is not checked and u have also not maintained any long text. Hence the error.
    By using #EC - you do not remove the error, however u hide it from SLIN.
    It is used if there is some known error you cannot avoid which is returned by SLIN and you dont want it to be reported. Also, a way to "cheat" the reviewer who might be checking for errors.
    Not good !! 
    Regards,
    Aditya

  • Checking naming convention of internal tables in code inspector

    Can anyone please explain how in the code inspector can I check names of internal tables (like it_) that I use in a report program ? I know that I can specify it_ in Programming Convention -> Naming Convention->Program Global -> Data but this entry is not specific to internal tables as it also applies to variables and work areas. Apart from this is there any entry I can maintain in the Extended Naming Conventions for Programs(introduced in ECC 6.0)? Kindly reply at the earliest.

    Hi,
    Check these links for implementing the custom conventions in the code inspector
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/nw/how%20to%20build%20a%20new%20check%20for%20the%20code%20inspector
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/evaluating%20the%20quality%20of%20your%20abap%20programs%20and%20other%20repository%20objects%20with%20the%20code%20inspector
    hope it helps you.
    Thanks!

  • ABAP Unit question

    Hello,
    I am new to ABAP unit, and not really sure on how I can execute one ABAP unit test script.
    Let's say I have the below code (extracted from SAPBC401_PRJD_ABAP_UNIT program in SAP ECC 6.0 system (SP9).
    **& Report  SAPBC401_PRJD_ABAP_UNIT
    REPORT  sapbc401_prjd_abap_unit.
    CLASS myclass DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA text TYPE string.
        CLASS-METHODS set_text_to_x.
    ENDCLASS.
    CLASS myclass IMPLEMENTATION.
      METHOD set_text_to_x.
        text = 'U'.
      ENDMETHOD.
    ENDCLASS.
    * Test classes
    CLASS mytest DEFINITION FOR TESTING.
      PRIVATE SECTION.
        METHODS mytestmethod FOR TESTING.
    ENDCLASS.
    CLASS mytest IMPLEMENTATION.
      METHOD mytestmethod.
        myclass=>set_text_to_x( ).
        cl_aunit_assert=>assert_equals( act = myclass=>text
                                        exp = 'X' ).
      ENDMETHOD.
    ENDCLASS.
    The simple question is, how I can execute the
    mytestmethod
    from
    mytest
    class?
    If I just execute the above code using F8, I believe nothing is executed right?
    I tried to append the below code, but it is also only executing the method in that particular class (not in the test case class).
    start-of-selection.
    myclass=>set_text_to_x( ).
    Please help me to start...
    Thanks in advanced.
    rgs,
    hiroshi

    Dear Klaus,
    Thanks very much! The link is very useful.
    I implemented the below class for test, and now I got the idea how to continue!
    class ZCL_WALLET definition
      public
      final
      create public .
    *"* public components of class ZCL_WALLET
    *"* do not include other source files here!!!
    public section.
      data LIQUIDITY type I .
      methods CHECK_LIQUIDITY .
      methods GET_LIQUIDITY
        returning
          value(RE_LIQUIDITY) type STRING .
      methods PUT_IN
        importing
          !EUROS type I .
    REPORT  Z_MAIN_ABAPUNIT.
    class lcl_Wallet_Test definition for testing. "#AU Risk_Level Harmless
      private section.
        methods check_Liquidity for testing.
    endclass.
    class lcl_Wallet_Test implementation.
    method check_Liquidity.
      data:
        my_Wallet type ref to zcl_Wallet,
        liquidity type i.
      create object my_Wallet.
      liquidity = my_Wallet->get_Liquidity( ).
      cl_Aunit_Assert=>assert_Equals(
        act = liquidity
        exp = 1 "purposely put 1 to show error
        msg = 'New wallet assumed empty' ).
      my_Wallet->put_In( euros = 12 ).
      cl_Aunit_Assert=>assert_Equals(
        act = my_Wallet->liquidity
        exp = 12
        msg = 'As many euros as put in before' ).
    endmethod.
    endclass.

Maybe you are looking for