Agile Javaв„ў: Crafting Code with Test-Driven Development

Let's summarize what the test is supposed to be doing, line by line:

Student student = new Student ("Jane Doe");

Create a student whose name is Jane Doe. Store it locally.

String studentName = student .getName();

Ask for the name of the student and store it in a local variable.

assertEquals("Jane Doe", studentName);

Make sure that the name of the student returned was Jane Doe.

That's a lot of things to know in order to understand a few short lines of code. However, you have already seen the foundation for a large part of Java programming. In welldesigned object-oriented Java coding, most statements involve either creating new objects, sending messages to other objects, or assigning object addresses (whether the objects are created via new or are returned from a message send) to an object reference.

Категории