1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Testing in Java

Connected

Exercise

Currency conversion

You are working on a currency trading platform. There is a utility class that converts between currencies. Its public convert() method takes an amount in the first currency and an exchange rate, and returns the value in another currency.

Your task is to make the project requirements for it part of the codebase by writing tests. A good place to start is to write a unit test for the success scenario for this method.

The necessary JUnit packages have been imported for you.

Instructions

100 XP
  • Call the convert() method with the currency and exchange rate.
  • Use the correct JUnit assertion to check that the convertedCurrency amount is equal to the expected one.