mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 15:16:33 -08:00
Testing added! Now some full behaviour tests on both Animal JVM implementations.
Still todo: Move the ConsoleTest library into its own module, add a gradle dependency on it.
This commit is contained in:
54
03_Animal/java/test/AnimalJavaTest.kt
Normal file
54
03_Animal/java/test/AnimalJavaTest.kt
Normal file
@@ -0,0 +1,54 @@
|
||||
import org.junit.Test
|
||||
|
||||
class AnimalJavaTest : ConsoleTest() {
|
||||
|
||||
@Test
|
||||
fun `given a standard setup, find the fish`() {
|
||||
assertConversation(
|
||||
"""
|
||||
$title
|
||||
ARE YOU THINKING OF AN ANIMAL ? {YES}
|
||||
DOES IT SWIM ? {YES}
|
||||
IS IT A FISH ? {YES}
|
||||
WHY NOT TRY ANOTHER ANIMAL?
|
||||
ARE YOU THINKING OF AN ANIMAL ? {QUIT}
|
||||
"""
|
||||
) {
|
||||
Animal.main(emptyArray())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given a standard setup, create a cow, and verify`() {
|
||||
assertConversation(
|
||||
"""
|
||||
$title
|
||||
ARE YOU THINKING OF AN ANIMAL ? {YES}
|
||||
DOES IT SWIM ? {NO}
|
||||
IS IT A BIRD ? {NO}
|
||||
THE ANIMAL YOU WERE THINKING OF WAS A ? {COW}
|
||||
PLEASE TYPE IN A QUESTION THAT WOULD DISTINGUISH A
|
||||
COW FROM A BIRD
|
||||
? {DOES IT EAT GRASS}
|
||||
FOR A COW THE ANSWER WOULD BE ? {YES}
|
||||
ARE YOU THINKING OF AN ANIMAL ? {YES}
|
||||
DOES IT SWIM ? {NO}
|
||||
DOES IT EAT GRASS ? {YES}
|
||||
IS IT A COW ? {YES}
|
||||
WHY NOT TRY ANOTHER ANIMAL?
|
||||
ARE YOU THINKING OF AN ANIMAL ? {QUIT}
|
||||
"""
|
||||
) {
|
||||
Animal.main(emptyArray())
|
||||
}
|
||||
}
|
||||
|
||||
private val title = """
|
||||
ANIMAL
|
||||
CREATIVE COMPUTING MORRISTOWN, NEW JERSEY
|
||||
|
||||
PLAY 'GUESS THE ANIMAL'
|
||||
THINK OF AN ANIMAL AND THE COMPUTER WILL TRY TO GUESS IT.
|
||||
"""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user