Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write a full answer and give a good explanation Testing 14. Imagine you w

ID: 3719328 • Letter: P

Question

Please write a full answer and give a good explanation

Testing 14. Imagine you want to implement a class Money that represents a certain amount of money in a certain currency. Using the method boolean isEqual (Money m) any instance of this class should be able to check if a given monetary amount m equals the amount stored in the instance itself. Following the test-driven development philosophy, implement eTest methods of a JUnit test fixture that prescribe how the isEqual method should behave when it receives a Money object m with: (10%) a) an equal amount in the same currency b) an unequal amount in the same currenc)y c) an amount in a different currency

Explanation / Answer

First I will show you the class I want to test:

The Unit Test

To test this class I require a unit test that test every one of its open strategies. The class just has one open strategy, isequal(), so all I have to test is this technique.

Unit tests are executed as classes with test techniques. Each test technique typically tests a solitary strategy for the objective class. Here and there, a test strategy can test in excess of one technique in the objective class, and some of the time, if the strategy to test is enormous, you split the test into numerous test strategies.

Here is the JUnit unit test that test that the isequal() method:

if(m==userinput)

system.out.println("Entered money is equal);

else

system.out.println("Not equal):

we can also use

the assertEquals() technique is called. It is this strategy that does the real testing. In this strategy we look at the yield of the called technique (isequals()) with the normal yield. At the end of the day, we look at m (expected yield) with the esteem returned by the client, which is kept in the variable inputuser.

On the off chance that the two qualities are equivalent, nothing happens. The assertEquals() technique returns regularly. On the off chance that the two qualities are not equivalent, a special case is tossed, and the test technique quits executing here.