1 /* 2 * Copyright (c) 2021 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockitoinline; 6 7 import org.junit.Test; 8 import org.mockito.Mockito; 9 10 import static org.hamcrest.CoreMatchers.*; 11 import static org.hamcrest.MatcherAssert.assertThat; 12 13 public class EnumMockingTest { 14 15 @Test testMockEnum()16 public void testMockEnum() { 17 Animal a = Mockito.mock(Animal.class); 18 assertThat(a, not(equalTo(Animal.CAT))); 19 assertThat(a.sound(), nullValue(String.class)); 20 assertThat(a.name(), nullValue(String.class)); 21 } 22 23 enum Animal { 24 CAT { 25 @Override sound()26 public String sound() { 27 return "meow"; 28 } 29 }; 30 sound()31 public abstract String sound(); 32 } 33 } 34