All files / src/env zcl_abapgit_feature.clas.testclasses.abap

86.13% Statements 87/101
57.14% Branches 4/7
100% Functions 4/4
86.13% Lines 87/101

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1021x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 1x 1x 1x 1x                     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
CLASS ltcl_feature DEFINITION FOR TESTING RISK LEVEL HARMLESS
  DURATION SHORT FINAL.
 
  PRIVATE SECTION.
 
    DATA mo_settings TYPE REF TO zcl_abapgit_settings.
    DATA mo_cut TYPE REF TO zcl_abapgit_feature.
 
    METHODS:
      setup,
      merged_disabled FOR TESTING,
      feature_disabled FOR TESTING,
      feature_enabled FOR TESTING.
 
ENDCLASS.
 
CLASS ltcl_feature IMPLEMENTATION.
 
  METHOD setup.
    CREATE OBJECT mo_cut.
    mo_settings = zcl_abapgit_persist_factory=>get_settings( )->read( ).
  ENDMETHOD.
 
  METHOD merged_disabled.
 
    IF zcl_abapgit_factory=>get_environment( )->is_merged( ) = abap_true.

      cl_abap_unit_assert=>assert_equals(
        act = mo_cut->is_enabled( )
        exp = abap_false ).

      cl_abap_unit_assert=>assert_equals(
        act = mo_cut->is_enabled( 'TEST' )
        exp = abap_false ).

    ENDIF.
 
  ENDMETHOD.
 
  METHOD feature_disabled.
 
    " Only run for dev version
    IF zcl_abapgit_factory=>get_environment( )->is_merged( ) = abap_true.
      RETURN.
    ENDIF.
 
    " All off
    mo_settings->set_experimental_features( '' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_enabled( 'TEST' )
      exp = abap_false ).
 
  ENDMETHOD.
 
  METHOD feature_enabled.
 
    " Only run for dev version
    IF zcl_abapgit_factory=>get_environment( )->is_merged( ) = abap_true.
      RETURN.
    ENDIF.
 
    " All on
    mo_settings->set_experimental_features( 'X' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_enabled( 'TEST' )
      exp = abap_true ).
 
    " Just one feature on
    mo_settings->set_experimental_features( 'TEST' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_enabled( 'TEST' )
      exp = abap_true ).
 
    " Several features on
    mo_settings->set_experimental_features( 'AFF,LXE' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_enabled( 'TEST' )
      exp = abap_false ).
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_enabled( 'AFF' )
      exp = abap_true ).
 
    " Several features on with whitespace
    mo_settings->set_experimental_features( ' AFF , FLOW   ,LXE ' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_enabled( 'TEST' )
      exp = abap_false ).
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_enabled( 'FLOW' )
      exp = abap_true ).
 
  ENDMETHOD.
 
ENDCLASS.