Commit addf2700 authored by Sahil's avatar Sahil
Browse files

Merge remote-tracking branch 'origin/qa-fixes' into test_updates

No related merge requests found
Pipeline #94054 failed with stage
in 0 seconds
Showing with 67 additions and 12 deletions
+67 -12
<component name="libraryTable"> <component name="libraryTable">
<library name="org.junit.jupiter:junit-jupiter:5.6.0-M1" type="repository"> <library name="junit.jupiter" type="repository">
<properties maven-id="org.junit.jupiter:junit-jupiter:5.6.0-M1" /> <properties maven-id="org.junit.jupiter:junit-jupiter:5.9.0-M1" />
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.6.0-M1/junit-jupiter-5.6.0-M1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.9.0-M1/junit-jupiter-5.9.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.6.0-M1/junit-jupiter-api-5.6.0-M1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.9.0-M1/junit-jupiter-api-5.9.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.6.0-M1/junit-platform-commons-1.6.0-M1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.9.0-M1/junit-platform-commons-1.9.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.6.0-M1/junit-jupiter-params-5.6.0-M1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.6.0-M1/junit-jupiter-engine-5.6.0-M1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.9.0-M1/junit-jupiter-params-5.9.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.6.0-M1/junit-platform-engine-1.6.0-M1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.9.0-M1/junit-jupiter-engine-5.9.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.9.0-M1/junit-platform-engine-1.9.0-M1.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />
......
<component name="libraryTable">
<library name="org.javassist:javassist:3.29.2-GA" type="repository">
<properties maven-id="org.javassist:javassist:3.29.2-GA" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/javassist/javassist/3.29.2-GA/javassist-3.29.2-GA.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
...@@ -13,6 +13,6 @@ ...@@ -13,6 +13,6 @@
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest:2.2" level="project" /> <orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest:2.2" level="project" />
<orderEntry type="library" name="org.hamcrest:hamcrest-core:2.2" level="project" /> <orderEntry type="library" name="org.hamcrest:hamcrest-core:2.2" level="project" />
<orderEntry type="library" name="com.github.javaparser:javaparser-core:3.5.12" level="project" /> <orderEntry type="library" name="com.github.javaparser:javaparser-core:3.5.12" level="project" />
<orderEntry type="library" name="org.junit.jupiter:junit-jupiter:5.6.0-M1" level="project" /> <orderEntry type="library" name="junit.jupiter" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -126,7 +126,7 @@ public class EvilHangmanChooserTests { ...@@ -126,7 +126,7 @@ public class EvilHangmanChooserTests {
@DisplayName("Expected makeGuess() exceptions for characters that aren't lower case for EvilHangmanChooser") @DisplayName("Expected makeGuess() exceptions for characters that aren't lower case for EvilHangmanChooser")
@Test @Test
@DependsOn("makeGuess") @DependsOn("makeGuess")
public void testMakeGuessExceptionsInEvil() { public void testMakeGuessLowercaseCharExceptionsInEvil() {
Constructor c = Reflection.getConstructor(EvilHangmanChooser.class, int.class, int.class); Constructor c = Reflection.getConstructor(EvilHangmanChooser.class, int.class, int.class);
EvilHangmanChooser chooser = Reflection.newInstance(c, 3, 1); EvilHangmanChooser chooser = Reflection.newInstance(c, 3, 1);
Method m = Reflection.getMethod(EvilHangmanChooser.class, "makeGuess", char.class); Method m = Reflection.getMethod(EvilHangmanChooser.class, "makeGuess", char.class);
...@@ -134,6 +134,28 @@ public class EvilHangmanChooserTests { ...@@ -134,6 +134,28 @@ public class EvilHangmanChooserTests {
IntStream.range(0, 20).forEach(i -> assertThrows(IllegalArgumentException.class, () -> Reflection.invoke(m, chooser, (char) ('z' + (i + 1))))); IntStream.range(0, 20).forEach(i -> assertThrows(IllegalArgumentException.class, () -> Reflection.invoke(m, chooser, (char) ('z' + (i + 1)))));
} }
@Order(sanityTestLevel + 4)
@DisplayName("Expected makeGuess() exceptions for characters that have been previously guessed for EvilHangmanChooser")
@TestDescription("This test makes sure that the makeGuess method throws exceptions for characters that have been guessed previously")
@DependsOn("makeGuess")
@Test
public void testMakeGuessRepeatedCharExceptionsInEvil() throws FileNotFoundException {
EvilHangmanChooser chooser = new EvilHangmanChooser(5, 5);
chooser.makeGuess('v');
assertThrows(IllegalArgumentException.class, () -> chooser.makeGuess('v'));
}
@Order(sanityTestLevel + 5)
@DisplayName("Expected makeGuess() exceptions if no guesses left for EvilHangmanChooser")
@TestDescription("This test makes sure that the makeGuess method throws exceptions if number of guesses left is not at least one")
@DependsOn("makeGuess")
@Test
public void testMakeTooManyGuessExceptionsInEvil() throws FileNotFoundException {
EvilHangmanChooser chooser = new EvilHangmanChooser(22, 2);
chooser.makeGuess('x');
chooser.makeGuess('y');
assertThrows(IllegalStateException.class, () -> chooser.makeGuess('z'));
}
} }
......
...@@ -132,13 +132,36 @@ public class RandomHangmanChooserTests { ...@@ -132,13 +132,36 @@ public class RandomHangmanChooserTests {
@TestDescription("This test makes sure that the makeGuess method throws exceptions for non-lowercase characters") @TestDescription("This test makes sure that the makeGuess method throws exceptions for non-lowercase characters")
@DependsOn("makeGuess") @DependsOn("makeGuess")
@Test @Test
public void testMakeGuessExceptionsInRandom() { public void testMakeGuessLowercaseCharExceptionsInRandom() {
Constructor c = Reflection.getConstructor(RandomHangmanChooser.class, int.class, int.class); Constructor c = Reflection.getConstructor(RandomHangmanChooser.class, int.class, int.class);
RandomHangmanChooser chooser = Reflection.newInstance(c, 3, 1); RandomHangmanChooser chooser = Reflection.newInstance(c, 3, 1);
Method m = Reflection.getMethod(RandomHangmanChooser.class, "makeGuess", char.class); Method m = Reflection.getMethod(RandomHangmanChooser.class, "makeGuess", char.class);
IntStream.range(0, 20).forEach(i -> assertThrows(IllegalArgumentException.class, () -> Reflection.invoke(m, chooser, (char) ('a' - (i + 1))))); IntStream.range(0, 20).forEach(i -> assertThrows(IllegalArgumentException.class, () -> Reflection.invoke(m, chooser, (char) ('a' - (i + 1)))));
IntStream.range(0, 20).forEach(i -> assertThrows(IllegalArgumentException.class, () -> Reflection.invoke(m, chooser, (char) ('z' + (i + 1))))); IntStream.range(0, 20).forEach(i -> assertThrows(IllegalArgumentException.class, () -> Reflection.invoke(m, chooser, (char) ('z' + (i + 1)))));
} }
@Order(sanityTestLevel + 4)
@DisplayName("Expected makeGuess() exceptions for characters that have been previously guessed for RandomHangmanChooser")
@TestDescription("This test makes sure that the makeGuess method throws exceptions for characters that have been guessed previously")
@DependsOn("makeGuess")
@Test
public void testMakeGuessRepeatedCharExceptionsInRandom() throws FileNotFoundException {
RandomHangmanChooser chooser = new RandomHangmanChooser(5, 5);
chooser.makeGuess('v');
assertThrows(IllegalArgumentException.class, () -> chooser.makeGuess('v'));
}
@Order(sanityTestLevel + 5)
@DisplayName("Expected makeGuess() exceptions if no guesses left for RandomHangmanChooser")
@TestDescription("This test makes sure that the makeGuess method throws exceptions if number of guesses left is not at least one")
@DependsOn("makeGuess")
@Test
public void testMakeTooManyGuessExceptionsInRandom() throws FileNotFoundException {
RandomHangmanChooser chooser = new RandomHangmanChooser(22, 2);
chooser.makeGuess('x');
chooser.makeGuess('y');
assertThrows(IllegalStateException.class, () -> chooser.makeGuess('z'));
}
} }
@DisplayName("Complete Functionality Tests") @DisplayName("Complete Functionality Tests")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment