please read all steps and also explain the answers
I also posted the code photos and text version
thank you
2. Take a look at Counter.java to see what it does.
3. You are going to create simple JUnit test class for this class. Right click on
Counter, and choose New->JUnit Test Class.
4. In the dialog box, make sure that JUnit5 is selected. The default name of the
class will be CounterTest, which is fine. Make sure that the setup() option is
checked. Select the class you will be testing (Counter).
5. Click Next. On the next dialog box, choose the methods you want to test:
increment and decrement. Click Finish. You might get a message about
adding JUnit5 to the build path. Click OK.
6. What is the automatically generated code? Try running it and see what
happens.
7. Now, fill in the methods. Use the CalculatorTest code as a model. The setup()
method should create Counter object, and the testIncrement and
testDecrement methods should test to see if the code works. Run the unit
test. What do you see? How do you know if the tests worked or not?
8. Introduce an error into one of the methods and return the tests. Now what
happens? How do you know there is an error?
Raw Version –
Counter —-
/**
* A counter class. Maintains a number
* representing a count
* @author Bonnie MacKellar
*
*/
public class Counter {
private int count = 0;
/**
* increment count by one
*
* @return incremented count
*/
public int increment() {
count = count + 1;
return count;
}
/**
* decrement count by one
*
* @return decremented count
*/
public int decrement() {
count = count – 1;
return count;
}
public int getCount() {
return count;
}
}
CounterTest ——
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Test;
class CounterTest {
@BeforeEach
void setUp() throws Exception {
}
@Test
public void testIncrement() {
fail(“Not yet implemented”);
}
@Test
public void testDecrement() {
fail(“Not yet implemented”);
}
@Test
public void testGetCount() {
fail(“Not yet implemented”);
}
}