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

Passage à AssertJ

parent a304bef3
No related branches found
No related tags found
No related merge requests found
Pipeline #1374 passed
......@@ -13,9 +13,9 @@ repositories {
}
dependencies {
testImplementation('org.junit.jupiter:junit-jupiter-api:5.7.2',
'org.hamcrest:hamcrest-library:2.2', 'net.obvj:junit-utils:1.3.1')
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.0',
'org.assertj:assertj-core:3.20.2')
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0'
}
test {
......
......@@ -2,8 +2,8 @@ package model;
import org.junit.jupiter.api.BeforeEach;
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 {
private Grid grid;
......@@ -15,26 +15,24 @@ public class GridTest {
@Test
public void testGetNeighbours(){
assertThat(grid.getNeighbors(1,1), is(notNullValue()));
assertThat(grid.getNeighbors(1,1), hasSize(equalTo(8)));
assertThat(grid.getNeighbors(1,1),
containsInAnyOrder(grid.getCell(0,0),
assertThat(grid.getNeighbors(1,1)).isNotNull();
assertThat(grid.getNeighbors(1,1)).hasSize(8);
assertThat(grid.getNeighbors(1,1))
.containsExactlyInAnyOrder(grid.getCell(0,0),
grid.getCell(0,1),
grid.getCell(0,2),
grid.getCell(1,0),
grid.getCell(1,2),
grid.getCell(2,0),
grid.getCell(2,1),
grid.getCell(2,2)));
grid.getCell(2,2));
}
@Test
public void testCountAliveNeighbours(){
assertThat(grid.countAliveNeighbors(1,1), is(equalTo(0)));
assertThat(grid.countAliveNeighbors(1,1)).isEqualTo(0);
grid.getCell(2,2).setState(CellState.RED);
grid.getCell(0,0).setState(CellState.RED);
assertThat(grid.countAliveNeighbors(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