Question: For the following, how do I write the Junit for them so that the expected result is met using the information in the message? this

For the following, how do I write the Junit for them so that the expected result is met using the information in the message? this is about chess pieces
1. Failed: testPawnKills(ChessPieceGraderTest)
Message: Unexpected canKill result for i=1 j=0 expected: but was:
2. Failed: testPawnMoves(ChessPieceGraderTest)
Message: Piece at :0,0, Unexpected canMove result for i=1 j=0 expected: but was:
some statements are false and others are true. attached is where im faling in my JUnit test and i need to fix it to pass those two errors.
-------------------------------------------------------------
/**
* Test whether a generic chess piece can move to certain spots.
*/
@Test
public void canMoveToTest() {
Piece genericBlackPiece = new Piece(standardBoard, BLACK);
Piece genericWhitePiece = new Piece(standardBoard, WHITE);
genericBlackPiece.moveTo(0,0);
genericWhitePiece.moveTo(2,2);
// A generic piece should be able to move anywhere, except ally spots
assertFalse(genericBlackPiece.canMoveTo(xGenericPieceLocation, yGenericPieceLocation)); // friendly
assertTrue(genericBlackPiece.canMoveTo(1, 1)); // empty
assertFalse(genericBlackPiece.canMoveTo(0, 0)); // same spot
assertTrue(genericBlackPiece.canMoveTo(2,2)); // enemy spot
}
/**
* Test to make sure pawns move properly.
*
* Note: White pawns move up, Black pawns move down.
*/
@Test
public void testPawnMovements(){
Pawn testPawn = new Pawn(standardBoard, WHITE, 3, 3);
//One step
assertTrue(testPawn.canMoveTo(2, 3));
//Two step first move
assertTrue(testPawn.canMoveTo(1, 3));
//Three step
assertFalse(testPawn.canMoveTo(0, 3));
//Back step
assertFalse(testPawn.canMoveTo(4, 3));
// Diagonal without enemies
assertFalse(testPawn.canMoveTo(2, 2));
// Diagonal with enemies
Pawn testPawn2 = new Pawn(standardBoard, BLACK, 2, 2);
assertTrue(testPawn.canMoveTo(2, 2));
// One step, black
assertTrue(testPawn2.canMoveTo(3, 2));
// back step, black
assertFalse(testPawn2.canMoveTo(1, 2));
//Invalid move, out-of-bounds
testPawn.moveTo(0, 0);
assertFalse(testPawn.canMoveTo(-1, 0));
// Invalid move, partner in front
testPawn.moveTo(3, 3);
Pawn testPawn3 = new Pawn(standardBoard, WHITE, 2, 3);
assertFalse(testPawn.canMoveTo(2, 3));
// Two step, already moved
testPawn3.moveTo(5, 5);
assertFalse(testPawn3.canMoveTo(3, 5));
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!