Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago