Junit Bug testing

Lab - Junit

Implement a Java class gInt (Gaussian Integer) and write a JUnit test suite. Use Ant to bring it all together.


A Gaussian integer is a number of the form a + b i, where a (the real part), b (the imaginary part) are integers, and i is the square root of -1.

They are added in a very normal way. (a + b i) + (c + d i) = (a+c) + (b+d) i.

Multiplication should also look familiar. (a + b i) * (c + d i) = (ac-bd) + (ad+bc) i.

The gInt class

This class should have, at a minimum, the following behavior:

gInt( int r ) - c'tor. Note, a real # is a complex number

gInt( int r, int i ) - c'tor

Note: No default c'tor. All objects must be initialised

int real() - the real part of the number

int imag() - the imaginary part of the number

gInt add( gint rhs ) - return a new gInt, the sum of this and rhs. Note, the object receiving this message is not modified.

gInt multiply( gint rhs ) - return a new gInt, the product of this and rhs. Note, the object receiving this message is not modified.

float norm() - return the L2-norm of the integer (the distance from the origin). The object is not modified.

Your test framework - the gIntTest class

You can name the methods how you'd like (as long as they're good names). You will provide a test for each method, above (but not for the c'tors).

Remember, a single test does not go far towards being reliable. Consider all of the preconditions and postconditions! They must be tested too, not simply that you "got the right answer".


Provide a build file that compiles your classes and runs the tests. The default target will be test, which depends on the compile target.


Use the example in this lab directory (Java/Junit) for guidance

One method at a time!

Write the comments (pre- and post-conditions) for each method first

Then write the corresponding test for that method

Then you actually implement the method



Submit the following files:

[url removed, login to view] - the gInt class

[url removed, login to view] - the TestCase for gInt

[url removed, login to view] - the Ant build file

README (opt.) - if you have anything to tell me before I grade the lab

Habilidades: PHP, Arquitetura de software

Veja mais: simply reliable software, real integers, l2, java distance, int i, integers and, integer real number, integer and real number, guidance software, first lab, first class objects in java, tor, testing framework, product testing, lab test, junit, form multiplication, bug testing, Java Software Testing , java write xml, test framework, lab java, write test conditions, real time ant, sum target

Acerca do Empregador:
( 0 comentários ) United States

ID do Projeto: #6774890

3 freelancers are bidding on average $23 for this job


I am #1 Java programmer on this site. Done 600+ projects. I am ready to do this with a well commented code. Thanks

$30 USD em 1 dia
(185 Comentários)

A proposal has not yet been provided

$25 USD em 1 dia
(3 Comentários)

Hi I have already created the project with all the requirement : Java class to implement GaussianInteger Junit Test class GaussianInteger Ant Build file.

$15 USD em 1 dia
(0 Comentários)