Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import static org.junit.Assert. * ; import org.junit.Before; import org.junit.Test; / / - - - - - - - - - - - - - -
import static org.junit.Assert.;
import org.junit.Before;
import org.junit.Test;
Test class for Calculator.
@author Stephen Edwards
@version
public class CalculatorTest
~ Setup
~ Instancestatic variables
private Calculator calc;
Creates a new Calculator object with zero in the accumulator.
@Before
public void setUp
calc new Calculator;
~ Public Methods
Check that a new calculator starts off with a zero value.
@Test
public void initial
assertEquals calc.getValue;
Check setValuegetValue
@Test
public void setValue
calc.setValue;
assertEquals calc.getValue;
calc.setValue;
assertEquals calc.getValue;
Check that clear returns the accumulator to zero.
@Test
public void clear
calc.setValue;
calc.clear;
assertEquals calc.getValue;
Check that add works on zero and nonzero accumulators.
@Test
public void addition
Add your own test actions here
calc.setValue;
calc.add;
assertEquals calc.getValue;
calc.add;
assertEquals calc.getValue;
Check that subtract works on zero and nonzero accumulators.
@Test
public void subtraction
Add your own test actions here
failDefine your test";
Check that multiplyBy works on nonzero accumulators.
@Test
public void multiplication
Add your own test actions here
failDefine your test";
Check that divideBy works on nonzero accumulators.
@Test
public void division
Add your own test actions here
calc.setValue;
calc.divideBy;
assertEquals calc.getValue;
calc.setValue;
calc.divideBy;
assertEquals calc.getValue;
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