-
Notifications
You must be signed in to change notification settings - Fork 0
Worker Movement Testing
Alexander Johnson edited this page Aug 29, 2022
·
3 revisions
These JUnit test cases aim to check if the WorkerMovementTask
passes the following functionality tests:
-
shouldMoveOnStart
: when thestart
method is called on the task, the entity should be moving towards the assigned target.
void shouldMoveOnStart() {
Vector2 target = new Vector2(10f, 10f);
WorkerMovementTask task = new WorkerMovementTask(target);
Entity entity = new Entity().addComponent(new PhysicsComponent());
PhysicsMovementComponent movementComponent = new PhysicsMovementComponent();
entity.addComponent(movementComponent);
entity.create();
task.create(() -> entity);
task.start();
assertTrue(movementComponent.getMoving());
assertEquals(target, movementComponent.getTarget());
assertEquals(Task.Status.ACTIVE, task.getStatus());
}
-
shouldStopWhenClose
: when the task is started and the position of the entity comes within stopping distance of the target (0.01f by default), then the entity should stop moving.
void shouldStopWhenClose() {
WorkerMovementTask task = new WorkerMovementTask(new Vector2(10f, 10f));
task.setStopDistance(1f); // Stopping distance for entity
Entity entity = new Entity().addComponent(new PhysicsComponent());
PhysicsMovementComponent movementComponent = new PhysicsMovementComponent();
entity.addComponent(movementComponent);
entity.setPosition(5f, 5f);
entity.create();
task.create(() -> entity);
task.start();
task.update();
assertTrue(movementComponent.getMoving());
assertEquals(Task.Status.ACTIVE, task.getStatus());
entity.setPosition(10f, 9f);
task.update();
assertFalse(movementComponent.getMoving());
assertEquals(Task.Status.FINISHED, task.getStatus());
}
-
shouldMoveToNewTarget
: when the task is started and the entity is moving towards its first target then, if the target is changed before the entity stops, it should move towards and stop at the second target.
void shouldMoveToNewTarget() {
Vector2 firstTarget = new Vector2(10f, 10f); // First entity target
WorkerMovementTask task = new WorkerMovementTask(firstTarget);
task.setStopDistance(1f); // Stopping distance for entity
Entity entity = new Entity().addComponent(new PhysicsComponent());
PhysicsMovementComponent movementComponent = new PhysicsMovementComponent();
entity.addComponent(movementComponent);
entity.setPosition(5f, 5f);
entity.create();
// Create WorkerMovementTask and assign entity
task.create(() -> entity);
task.start();
task.update();
assertTrue(movementComponent.getMoving());
assertEquals(Task.Status.ACTIVE, task.getStatus());
// Change target of entity
Vector2 secondTarget = new Vector2(-10f, -10f);
task.setTarget(secondTarget);
// Move entity next to first target; should still be moving
entity.setPosition(10f, 9f);
task.update();
assertTrue(movementComponent.getMoving());
assertEquals(Task.Status.ACTIVE, task.getStatus());
// Move entity next to second target; should stop moving
entity.setPosition(-10f, -9f);
task.update();
assertFalse(movementComponent.getMoving());
assertEquals(Task.Status.FINISHED, task.getStatus());
}
Map
City
Buildings
Unit Selections
Game User Testing: Theme of Unit Selection & Spell System
Health Bars
In Game menu
- Feature
- User Testing:In Game Menu
Landscape Tile Design Feedback