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