Question: Please write this I am not clear on the subject. There is another answer out there on Chegg but it is not what I am

Please write this I am not clear on the subject. There is another answer out there on Chegg but it is not what I am looking for, please don't copy that :)

Use the following JUnit test to simulate a Test Driven Development environment. Place the test class into a project, and write a class so that the test compiles.

Run the test, and modify your class until it passes the first test.

Uncomment the next test, and modify your class until it passes that test.

Repeat this process until your class support all of the tests in the test class.

import static org.junit.Assert.*;

import org.junit.Test;

public class CounterTest {

// FIRST // Write a class Counter such that the following test works @Test public void testZero() { Counter cnt = new Counter(0); assertEquals("initial value of (0) failed", 0, cnt.getCount());

cnt.increase(); assertEquals("increased value of (0) failed", 0, cnt.getCount());

cnt.decrease(); assertEquals("decreased value of (0) failed", 0, cnt.getCount()); }

// SECOND // Uncomment the following method, // modify your Counter class so that this test works. /* @Test public void testIncrease() { Counter cnt = new Counter(7); assertEquals("initial value of (7) failed", 0, cnt.getCount());

cnt.increase(); assertEquals("increased once value of (7) failed", 7, cnt.getCount());

cnt.increase(); assertEquals("twice increased once value of (7) failed", 14, cnt.getCount()); } */

// THIRD // Uncomment the following method, // modify your Counter class so that this test works. /* @Test public void testDecrease() { Counter cnt = new Counter(11); cnt.decrease(); assertEquals("decreased value of (11) failed", -11, cnt.getCount());

cnt.decrease(); assertEquals("twice decreased value of (11) failed", -22, cnt.getCount()); } */

// FOURTH // Uncomment the following method, // modify your Counter class so that this test works. /* @Test public void testNegative() { Counter cnt = new Counter(-1); cnt.decrease(); assertEquals("decreased value of (-1) failed", 1, cnt.getCount());

cnt.increase(); assertEquals("decreased/increased value of (-1) failed", 0, cnt.getCount());

cnt.increase(); assertEquals("decreased/increased/increased value of (-1) failed", -1, cnt.getCount()); } */ }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!