Skip to topic | Skip to bottom
Minfo.GlTD2y1314r1.1 - 14 Oct 2013 - 13:18 - PhilippeCollettopic end

Start of topic | Skip to actions

TD 2 : tests unitaires


Le retour de la créature

Download and create a new project for this lab. It contains :

  • a correction for the SmartCreature
  • some small changes with some methods moved at appropriate places
  • the code for a BouncingCreature :
    • it randomly changes direction (see the "noise" part)
    • it is supposed to bounce on the wall
But it is buggy... Run the launcher and see.

Exercice 1 : premier test

  • Think on how to organize tests (what is the surrounding setup, what are you going to test, how, which values, etc.)
  • Create a first test (use the wizard and use help on fixing the project setup to include junit library)

Exercice 2 : le jeu des 3 erreurs

There are 3 errors in the BouncingCreature. Find them with the right tests and correct the code.

Exercice 3 : objets mock

Set up:

  1. Download mockito library mockito-all-1.9.5.jar
  2. Create a new directory in your project called lib
  3. Copy there the downloaded mockito jar file
  4. Right click the jar file and select Build Path -> Add to build path

Change the previous tests so to mock the environment: think of the methods that are used by the creature...

Exercise 4: test de l'émergence

  • Create a single test (with mock as well) to verify the basic algorithm of the SmartCreature.
  • Add to this test some "verify" statement of mockito to check the interactions between the creature and its environment.

-- PhilippeCollet - 14 Oct 2013
to top

You are here: Minfo > GlTD2y1314

to top

Copyright © 1999-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WIKIDeptinfo? Send feedback