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.

3

ABAP Unit and Test-Driven Development

be managed by both business experts and developers. You will notice that the

naming conventions for test methods used throughout this chapter adhere to the

BDD recommendations that are about to be explained.

When using behavior-driven development, the general recommendation is to

start all the test methods with IT SHOULD, with the IT referring to the application

being tested (the class under test). Thus, you would have names such as IT SHOULD

FIRE A NUCLEAR MISSILE, such names coming straight out of the specification that

describes what the program is supposed to achieve.

In ABAP, you are limited to 30 characters for names of methods, variables, database

tables, and so on—so you have to use abbreviations, which potentially

makes ABAP less readable than languages like Java. In Java, you would have

really long test method names, like It Should Return a BOM For a Purple Monster,

but in ABAP you can’t afford to add the extra characters of IT SHOULD to the

method name. Instead, you can put the IT SHOULD in a comment line with dots

after it, padding the comment line out to 30 characters to make it really obvious

what the maximum permitted length of the names of the test methods are. You

will then declare the test methods unde rneath the dotted line and be aware of

when you are running out of space for the name. An example of this is shown in

Listing 3.29.

*--------------------------------------------------------------*

* Specifications

*--------------------------------------------------------------*

"IT SHOULD.....................

"User Acceptance Tests

return_a_bom_for_a_monster FOR TESTING,

Listing 3.29 Test Methods That Describe What an Application Should Do

Other Names for Behavior-Driven Development

Sometimes, these sorts of behavior-driven development unit tests are described as user

acceptance tests. Although there is no actual user involved, the reason for the terminology

is that this sort of test simulates the program exhibiting a behavior that the user

would expect when he performs a certain action within the program. Outside of SAP,

the testing framework called FitNesse describes itself as such an automated user acceptance

testing framework.

You may also see behavior-driven development referred to as the Assemble/Act/Assert

way of testing (which doesn’t read as much like natural language, but it makes some

people very happy, because every word starts with the same letter).

172

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

Saved successfully!

Ooh no, something went wrong!