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

Connected

Exercise

Unit test: Foreign exchange market

Let's practice creating and programming mocks in the banking context! Complete the unit test for the ExchangeApp, which uses the European Central Bank. As you're testing the convertEuroTo() logic, don't mock it. Instead, mock its dependency so that you can check if it works properly!

The necessary JUnit and Mockito packages have been imported for you.

Instructions

100 XP
  • Create a mock for the EuropeanCentralBankServer.
  • Use the correct syntax to program the mock to return 12345.0.
  • Verify the currency conversion returns the desired output.