Skip to content

Turret Test Test Plan

McArthur edited this page Oct 4, 2023 · 1 revision

The current iteration of the turret test suite was non functional at the start of sprint 2 due to poor use of mockito. This test plan is somewhat retroactive as part of bug teams effort to document undocumented code, but also serves as an update to the changes made to the test suite.

setUp (BeforeEach):

Previously the tests did not use mockito and as a result had to be commented out due to failures. The following changes were implemented at setup time to resolve this:

  • All required services are set up. These include the resourceService, physicsService and renderService. They are registered with the Service Locator.
  • Special mocks are put in place on the resource service to supply a mocked TextureAtlas when requested.
  • Special mocks are put in place on the physics service to supply a PhysicsEngine when requested.
  • A turret is initialized for use in the tests. This is to prevent leakage between tests.

Test Case 1: testRefillAmmo()

This test verifies that the ammo refill functionality of turrets is functioning appropriately. It should assert that, after refilling ammo, the expected amount is present. This will test refilling ammo at differing amounts of ammo provide the correct amount. The test previously used white box testing, but will be moved to a getter for black box testing.

Test Case 2: testCanFire()

This test verifies that canFire works as expected. It tests canFire with varying amounts of currentAmmo on the turret. This also previously used white box testing, but will be moved to using getters and setters for currentAmmo. Additionally, negataive ammo will be tested.

Test Case 3: testRefillAmmoWithAmount()

This test verifies that refill ammo, when given a non default amount, correctly refills ammo by that ammount up to the maximum ammo. Previously this used white box testing, but will be moved to use getters and setters.

Clone this wiki locally