Skip to content

Commit

Permalink
Fixed failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Aug 6, 2024
1 parent 423d125 commit 18b90db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import megamek.common.equipment.WeaponMounted;
import megamek.common.options.GameOptions;
import megamek.common.options.OptionsConstants;
import megamek.common.planetaryconditions.PlanetaryConditions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -258,6 +259,9 @@ public void testGetEntityToMove() {
when(mockGame.getTurn()).thenReturn(mockTurn);
when(mockTurn.isValidEntity(any(Entity.class), any(Game.class))).thenCallRealMethod();
when(mockTurn.isValidEntity(any(Entity.class), any(Game.class), anyBoolean())).thenCallRealMethod();
PlanetaryConditions mockPC = new PlanetaryConditions();
mockPC.setGravity(1.0f);
when(mockGame.getPlanetaryConditions()).thenReturn(mockPC);
when(mockPrincess.getGame()).thenReturn(mockGame);

List<Entity> testEntityList = new ArrayList<>();
Expand Down Expand Up @@ -450,6 +454,9 @@ public void testIsImmobilized() {
when(mockPrincess.getHex(any(Coords.class))).thenReturn(mockHex);

Game mockGame = mock(Game.class);
PlanetaryConditions mockPC = new PlanetaryConditions();
mockPC.setGravity(1.0f);
when(mockGame.getPlanetaryConditions()).thenReturn(mockPC);
doReturn(mockGame).when(mockPrincess).getGame();

BehaviorSettings mockBehavior = mock(BehaviorSettings.class);
Expand Down
9 changes: 6 additions & 3 deletions megamek/unittests/megamek/common/MovePathTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
*/
package megamek.common;

import megamek.common.planetaryconditions.PlanetaryConditions;
import org.junit.jupiter.api.Test;

import java.util.Vector;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.*;

/**
* @author Deric "Netzilla" Page (deric dot page at usa dot net)
Expand All @@ -37,6 +36,10 @@ public class MovePathTest {
@Test
public void testGetLastStep() {
Game mockGame = mock(Game.class);
PlanetaryConditions mockPC = new PlanetaryConditions();
mockPC.setGravity(1.0f);
when(mockGame.getPlanetaryConditions()).thenReturn(mockPC);

Entity mockMech = mock(BipedMech.class);

Vector<MoveStep> stepVector = new Vector<>();
Expand Down

0 comments on commit 18b90db

Please sign in to comment.