Skip to content
Snippets Groups Projects
Commit 15ab66ec authored by LABOUREL Arnaud's avatar LABOUREL Arnaud
Browse files

Passage à AssertJ

parent 08632686
No related branches found
No related tags found
No related merge requests found
...@@ -13,9 +13,9 @@ repositories { ...@@ -13,9 +13,9 @@ repositories {
} }
dependencies { dependencies {
testImplementation('org.junit.jupiter:junit-jupiter-api:5.7.2', testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.0',
'org.hamcrest:hamcrest-library:2.2', 'net.obvj:junit-utils:1.3.1') 'org.assertj:assertj-core:3.20.2')
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0'
} }
test { test {
......
...@@ -90,12 +90,12 @@ public class Grid implements Iterable<Cell> { ...@@ -90,12 +90,12 @@ public class Grid implements Iterable<Cell> {
// TODO: Écrire une version correcte de cette méthode. // TODO: Écrire une version correcte de cette méthode.
public List<Cell> getNeighbours(int rowIndex, int columnIndex) { public List<Cell> getNeighbors(int rowIndex, int columnIndex) {
return null; return null;
} }
// TODO: Écrire une version correcte de cette méthode. // TODO: Écrire une version correcte de cette méthode.
public int countAliveNeighbours(int rowIndex, int columnIndex) { public int countAliveNeighbors(int rowIndex, int columnIndex) {
return 0; return 0;
} }
......
...@@ -2,8 +2,8 @@ package model; ...@@ -2,8 +2,8 @@ package model;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.assertThat;
public class GridTest { public class GridTest {
private Grid grid; private Grid grid;
...@@ -14,27 +14,25 @@ public class GridTest { ...@@ -14,27 +14,25 @@ public class GridTest {
} }
@Test @Test
public void testGetNeighbours(){ public void testGetNeighbors(){
assertThat(grid.getNeighbours(1,1), is(notNullValue())); assertThat(grid.getNeighbors(1,1)).isNotNull();
assertThat(grid.getNeighbours(1,1), hasSize(equalTo(8))); assertThat(grid.getNeighbors(1,1)).hasSize(8);
assertThat(grid.getNeighbours(1,1), assertThat(grid.getNeighbors(1,1))
containsInAnyOrder(grid.getCell(0,0), .containsExactlyInAnyOrder(grid.getCell(0,0),
grid.getCell(0,1), grid.getCell(0,1),
grid.getCell(0,2), grid.getCell(0,2),
grid.getCell(1,0), grid.getCell(1,0),
grid.getCell(1,2), grid.getCell(1,2),
grid.getCell(2,0), grid.getCell(2,0),
grid.getCell(2,1), grid.getCell(2,1),
grid.getCell(2,2))); grid.getCell(2,2));
} }
@Test @Test
public void testCountAliveNeighbours(){ public void testCountAliveNeighbors(){
assertThat(grid.countAliveNeighbours(1,1), is(equalTo(0))); assertThat(grid.countAliveNeighbors(1,1)).isEqualTo(0);
grid.getCell(2,2).setState(CellState.ALIVE); grid.getCell(2,2).setState(CellState.ALIVE);
grid.getCell(0,0).setState(CellState.ALIVE); grid.getCell(0,0).setState(CellState.ALIVE);
assertThat(grid.countAliveNeighbours(1,1), is(equalTo(2))); assertThat(grid.countAliveNeighbors(1,1)).isEqualTo(2);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment