14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1

ABAP in Eclipse

They say that little things please little minds, but I take great pleasure in being

able to write the method definition for the method that will not be tested, pressing

(CTRL) + (1) and having the implementation created for me, and having the

cursor jump into the implementation. Another cliché says that every second

counts, and if these tools save a few se conds here and there all throughout your

working day, then over time that does all add up.

CLASS ycl_monster_unit_tests IMPLEMENTATION.

METHOD first_monster.

WRITE:/ 'I am the First Monster'.

ENDMETHOD.

METHOD second_monster.

WRITE:/ 'I am the Second Monster'.

ENDMETHOD.

ENDCLASS. "Monster Unit Tests Implementation

Listing 1.14 The Method that Will Not Be Tested

If you were in SE80, you would now follow the menu path Program 폷 Test 폷 Unit

Test; the equivalent in ABAP in Eclipse is to press (CTRL) + (SHIFT) + (F10). That’s

wonderful; you’ll s ee any errors that may have cropped up as a result of any

changes you might have made. However, you want to take this to the next level,

so instead press (CTRL) + (SHIFT) + (F11). (Eleven is obviously a better number than

10, in the same way that they started ca lling hotels six-star hotels because five

stars weren’t good enough anymore.)

Now, you’ll see two results (Figure 1.20). First, all the code that was tested is

highlighted; more importantly, you’ll see a summary view, which indicates what

percentage of each method was tested by the automated unit tests.

Figure 1.20 Unit Test Coverage

This is the sort of information you want shoved in your face like a custard pie,

first because you want to make sure all the vital parts of your program are covered

66

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!