Skip to content

Worker Idle Testing

Alexander Johnson edited this page Aug 29, 2022 · 2 revisions

Overview

These JUnit test cases aim to check if the WorkerIdleTask passes the following functionality tests:

  1. shouldNotMoveOnStart: when the start method is called on the task and updated, the unit should not be moving
void shouldNotMoveOnStart() {
        Vector2 startPosition = new Vector2(10.0f, 10.0f);
        WorkerIdleTask task = new WorkerIdleTask();
        Entity entity = new Entity().addComponent(new PhysicsComponent());
        PhysicsMovementComponent movementComponent = new PhysicsMovementComponent();
        entity.addComponent(movementComponent);
        entity.create();
        entity.setPosition(startPosition.x, startPosition.y);

        task.create(() -> entity);
        task.start();
        task.update();
        // Check to make sure that entity hasn't moved
        assertEquals(Task.Status.FINISHED, task.getMovementTask().getStatus());
        assertEquals(entity.getPosition(), startPosition);
    }
  1. shouldBeIdle: when the task is started and the unit is not currently moving, the idling attribute of the task should be set as false
void shouldBeIdle() {
        WorkerIdleTask task = new WorkerIdleTask();
        Entity entity = new Entity().addComponent(new PhysicsComponent());
        PhysicsMovementComponent movementComponent = new PhysicsMovementComponent();
        entity.addComponent(movementComponent);
        entity.create();

        task.create(() -> entity);
        task.start();
        task.update(); // Should have stopped
        task.update(); // Should have updated idling to true
        assertTrue(task.isIdling());
    }
  1. shouldNotBeIdle: when the task is started and the unit is currently moving, the idling attribute of the task should be set as true
void shouldNotBeIdle() {
        Vector2 startPosition = new Vector2(10.0f, 10.0f);
        WorkerIdleTask task = new WorkerIdleTask();
        Entity entity = new Entity().addComponent(new PhysicsComponent());
        PhysicsMovementComponent movementComponent = new PhysicsMovementComponent();
        entity.addComponent(movementComponent);
        entity.create();
        entity.setPosition(startPosition);

        task.create(() -> entity);
        task.start();
        task.update(); // Should have stopped
        task.update(); // Should have updated idling to true
        assertTrue(task.isIdling()); // Should be idle

        task.startMoving(new Vector2(15.0f, 15.0f));
        assertFalse(task.isIdling()); // Should be moving
        task.update();
        assertFalse(task.isIdling()); // Should still be moving
    }

Table of Contents

Home

Game

Game Home

Design Influences

Gameplay Features

Style

Story

Friendly Units
Map
City
Buildings
Unit Selections

Spell

Game User Testing: Theme of Unit Selection & Spell System

UI User Testing

Tutorial

Resource Stats Display

Loading Screen Bar

Health Bars
In Game menu
  • Feature
  • User Testing:In Game Menu

Landscape Tile Design

Landscape Tile Design Feedback

Weather Design

Weather Design Feedback

Camera Movement

Enemy design

Enemy Units

Enemy AI

How Animation Works

Map Flooding

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally