SlideServe
Menu
Préférences
© SlideServe · v2026

Implementing Classes and JUnit Testing in Object-Oriented Software Development

ronny avatar
7 diapositives · 213 Views · Jul 28, 2014

In this session, we explore the implementation of classes and interfaces in object-oriented software development through practical examples. We will create the `Shouter` class with documented stubs, covering important concepts like stubs, Javadoc documentation, and the construction of our class. We will also write JUnit tests to verify the functionality of the `Shouter` constructors and methods. Key points include understanding field declarations, initialization, and debugging tests to ensure robust software design. Join us for an engaging session on best practices in coding and testing.

Implementing Classes and JUnit Testing in Object-Oriented Software Development - slide 1
01 / 7Implementing Classes and JUnit Testing in Object-Oriented Software Development
1 / 17

Télécharger la présentation

Implementing Classes and JUnit Testing in Object-Oriented Software Development
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. CSSE 220 Object-Oriented Software Development Session 3 • Implementing a class • Implementing an interface • Using documented stubs before coding • Writing JUnit tests before coding • Using fields

  2. Shouter • Step 1: Create the Shouter class with documented stubs Do you see: • What is a stub? • What is adocumentedstub? • What must you document? (Answer: every public thing) • What is the form for a Javadoc? • What does “implements StringTransformable” mean? Why is it important? • What is the form of this class? • What is a constructor? Questions on the above?Did you get yours peer-reviewed?

  3. Shouter Step 2: Write JUnit tests for the constructors and methods of Shouter Do you see why: • We test only translate here? • There is a field for a Shouter object? • How setup initializes that field? • How assertEquals works? Test cases continue on the next slides.

  4. Shouter Step 2: Write JUnit tests for the constructors and methods of Shouter Do you see why: • These are good test cases? One last test case – testing long Strings – is on the next slide.

  5. Shouter Step 2: Write JUnit tests for the constructors and methods of Shouter Do you see why: • How this uses concat and assignment to build long Strings? • We should perhaps test how long the method takes? JUnit can do that, but we won’t take the time to do so today. Questions on JUnit tests?

  6. Shouter Step 3: Implement the class, then test and debug code and/or tests. Do you see: • Why implementing transform: • starts with stringToTransform? • Continues with a dot? • How you found the right method (toUpperCase) to call? • Why you don’t need a local variable in transform? • Why the constructor does nothing? • Why you should have the comment that it does nothing?

  7. Fields • What are fields (aka member variables) of a class? • When does a class need fields? • Example: TestShouter needs a field. • What is the field? • Why is it needed? • How is it initialized? • Example: Censor needs a field. • What is the field? • Why is it needed? • How is it initialized?