Question
Can anyone make class from these unit-test. I need a actual code to pass these tests. import org.hamcrest.Matchers; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; public
Can anyone make class from these unit-test. I need a actual code to pass these tests.
import org.hamcrest.Matchers;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
public abstract class NumberGuesserTest
{
protected void badGuess(final NumberGuesser guesser)
{
badGuess(guesser, 1, 0, "min (1) must be <= max (0)");
badGuess(guesser, 100, 1, "min (100) must be <= max (1)");
badGuess(guesser, 100, 99, "min (100) must be <= max (99)");
}
private void badGuess(final NumberGuesser guesser,
final int min,
final int max,
final String expectedMessage)
{
Throwable ex;
ex = assertThrows(IllegalArgumentException.class, () -> { guesser.guess(min, max); } );
assertThat(ex.getMessage(), Matchers.equalTo(expectedMessage));
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started