14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Automating the Test Process 3.4

support for this. From release 7.31 of ABAP, you can follow the menu path Local

Test Classes 폷 Execute 폷 Execute Tests With 폷 Code Coverage. As mentioned earlier

in the book, the same feature is available with ABAP in Eclipse.

3.4 Automating the Test Process

In the example presented in this chapter, the code was deliberately simple in

order to highlight the basic principles without getting bogged down with unnecessary

detail. However, in the real world programs are never simple. Even if they

start off simple, they keep growing and mutating, the ground of the original purpose

getting buried under the ever-falling snow of new functionality.

If you think about what you have read above, you will see that this can lead to

quite a large effort in writing the test code, in two areas:

왘 Setting up the class under test via the SETUP method

Well-designed object-oriented programs use lots of small reusable classes, and

these often need to be inserted into the main class during construction. The

smaller classes often need still smaller cl asses inserted into them during their

construction, and so on. In practical terms, this can mean a lot of lines of code

to build up your test class, passing in assorted mock doubles as well as elementary

data parameters, such as date, and organizational elements, such as plant

or sales organization.

왘 Creating mock objects

Although you need mock objects to take the place of real objects during a test,

in order to avoid actual database access and the like it can take a good deal of

effort to create these and to write the logic inside them to return hard-coded

values. Even worse, if yo u are passing in constructor objects as interfaces as

opposed to actual classes (which all the OO experts recommend), then you

need to expend even more effort, beca use you have to create an implementation

for every method in your mock objectthat uses the interface, including the

methods you are not interested in.

Luckily, there are solutions for both problems. Neither are anything you will find

in the SAP standard, but both solutions use the multitude of tools available within

the ABAP environment.

161

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

Saved successfully!

Ooh no, something went wrong!