Question: Can someone help me with JUnit testing in Java? I'm very new to it and don't quite understand. The following is what I have to

Can someone help me with JUnit testing in Java? I'm very new to it and don't quite understand.

The following is what I have to do:

Here is what I have to do

1. Use assertNotNull() to test the Complex(double, double) constructor

2. Use assertEquals(double, double, double) to test if getReal() returns the correct value set using the Complex(int, int) constructor

3. Use assertEquals(double, double, double) to test if setReal() correctly resets the value set using the Complex(double, double) constructor

4. Use the no-arg Complex() constructor, and then use the real and imaginary setters to set new integer values. Then use assertTrue(boolean) to test the validity of your newly-added equals(int, int) method

5. Using assertTrue(boolean), test that two Complex numbers created using the Complex(String[]) constructor and the Complex(String, String) constructor give the correct result using the multiply() method. Use equals(Complex) to compare the actual and expected result

6. Divide two Complex numbers and use the result to test your equals(double expected, double actual, double delta) method, with delta = .0000001

Here is my class code for class Complex

Can someone help me with JUnit testing in Java? I'm very new

to it and don't quite understand. The following is what I have

And for class ComplexCalculator

to do: Here is what I have to do 1. Use assertNotNull()

to test the Complex(double, double) constructor 2. Use assertEquals(double, double, double) to

I tried doing it but only first one funs and the rest fail

test if getReal() returns the correct value set using the Complex(int, int)

Please take the time to explain what you did. Thanks so much

eclipse-workspace-CS18284-Lab04/src/cst8284/calculator/Complexava-Eclipse File Edit Scurce Refatr Navigate Search Preject Rur Winduw Help 1 package cst8284.calculator 3 public class Conplex \ private double real = e; privata doublo ina // Complex ranstructor that takrs in a single string, r.E- 2-4i. 9 public Conplex(String Str this(cstr.split"?V)"): splits cstr ator into an array of strings having two elenents The first elenrnt of thr resultant array wil1 he the rral portion, while the second is the imaginary porLio This array is passed to Lhe riext constructor 12 13 14 Complex constructor that takes in an array of two strings fron the above constructor 17 1 public Conplex(String] cStr) 19 this(cStr[el, cstr[11); 21 23 Conplex ranstructor that takrs two separate strings as parameters, r.g. "" and Ai" 24 public Conplex(Strirng r, String i) this(Integer parseint(r), Integer parselnt(i.replace"))) 06 Complex ronstructor that takrs in tun ints as paraneters, .e-2 and- public Conplex(int r, int i) 31 this (double)r, (double)i); 34 // Complex ranstructor that takes in tun ints and stares then as floats, r.E- as ).e and .4. 6 public Conplex(double , double i) 3/ this.setReal(r); this-set Tmng(1 ) ; 11 idefault Complex constructorg it should rhain autonatically 42 public Conplex)this(,8); 45 public double getReal Smart Insert71: 109

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!