Changed to parameterized test
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -52,6 +52,13 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-params</artifactId>
|
||||||
|
<version>5.9.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import static org.mockito.Mockito.verify;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.CsvSource;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
@@ -473,34 +475,18 @@ public class TestTrifid{
|
|||||||
verify(logger, times(1)).debug("Getting character at {} {} {}", 2, 0, 1);
|
verify(logger, times(1)).debug("Getting character at {} {} {}", 2, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testGetChar_largeX(){
|
@CsvSource({
|
||||||
|
"3, 1, 2",
|
||||||
|
"0, 3, 2",
|
||||||
|
"0, 1, 3"
|
||||||
|
})
|
||||||
|
public void testGetChar_invalidLocation(int x, int y, int z){
|
||||||
cipher.grid = grid;
|
cipher.grid = grid;
|
||||||
|
CharLocation location = cipher.new CharLocation(x, y, z);
|
||||||
|
|
||||||
assertThrows(InvalidCharacterException.class, () -> {
|
assertThrows(InvalidCharacterException.class, () -> {
|
||||||
cipher.getChar(cipher.new CharLocation(3, 1, 2));
|
cipher.getChar(location);
|
||||||
});
|
|
||||||
|
|
||||||
verify(logger, never()).debug(eq("Getting character at {} {} {}"), anyInt(), anyInt(), anyInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetChar_largeY(){
|
|
||||||
cipher.grid = grid;
|
|
||||||
|
|
||||||
assertThrows(InvalidCharacterException.class, () -> {
|
|
||||||
cipher.getChar(cipher.new CharLocation(0, 3, 2));
|
|
||||||
});
|
|
||||||
|
|
||||||
verify(logger, never()).debug(eq("Getting character at {} {} {}"), anyInt(), anyInt(), anyInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetChar_largeZ(){
|
|
||||||
cipher.grid = grid;
|
|
||||||
|
|
||||||
assertThrows(InvalidCharacterException.class, () -> {
|
|
||||||
cipher.getChar(cipher.new CharLocation(0, 1, 3));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
verify(logger, never()).debug(eq("Getting character at {} {} {}"), anyInt(), anyInt(), anyInt());
|
verify(logger, never()).debug(eq("Getting character at {} {} {}"), anyInt(), anyInt(), anyInt());
|
||||||
|
|||||||
Reference in New Issue
Block a user