Unit testing Feign clients
Let's create a unit test class; this test class can have several test methods but in this example, we have created three @Test
methods, to test our client. The test will use static imports from the org.hamcrest.CoreMatchers.*
and org.junit.Assert.*
 packages:
@Test public void findAllAccountTest() throws Exception { List<Account> accounts = accountService.findAll(); assertTrue(accounts.size() > 4); } @Test public void findOneAccountTest() throws Exception { Account account = accountService.findByAccountId(1001); assertThat(account.getCustmer().getCustomerName(), containsString("Arnav")); } @Test public void createAccountTest() throws Exception { Account account = new Account(1001, 2304.32, 100, 'SAVING', 'HDFC0011', 'HDFC') accountService.create(account); account = accountService.findByAccountId(1001); assertThat(account.getBank(), containsString("HDFC")); }
We have written unit test cases to...