Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Poslovitch committed Apr 9, 2020
1 parent 7c3ba68 commit 80fc4a7
Showing 1 changed file with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
*
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({Bukkit.class, BentoBox.class, Utils.class, Util.class})
@PrepareForTest({Bukkit.class, BentoBox.class, Utils.class, Util.class, User.class})
public class AddBiomeCommandTest {

@Mock
Expand Down Expand Up @@ -96,14 +96,6 @@ public class AddBiomeCommandTest {
@Mock
private Inventory top;


@BeforeClass
public static void beforeClass() throws Exception {
PowerMockito.mockStatic(Bukkit.class);
// version - has to be 1.13 because code is only built to 1.13
when(Bukkit.getBukkitVersion()).thenReturn("1.13");
}

/**
* @throws java.lang.Exception
*/
Expand Down Expand Up @@ -142,6 +134,7 @@ public void setUp() throws Exception {
when(world.getName()).thenReturn("BSkyBlock_world");

// Player
PowerMockito.mockStatic(User.class);
// Sometimes use Mockito.withSettings().verboseLogging()
when(user.isOp()).thenReturn(false);
uuid = UUID.randomUUID();
Expand Down Expand Up @@ -247,10 +240,8 @@ public void testCanExecutePlayerNoArgs() {
*/
@Test
public void testCanExecuteConsoleNoArgs() {
CommandSender sender = mock(CommandSender.class);
User console = User.getInstance(sender);
assertFalse(abc.canExecute(console, "add", Collections.emptyList()));
verify(lm).get(eq(console), eq("commands.help.header"));
when(user.isPlayer()).thenReturn(false);
assertFalse(abc.canExecute(user, "add", Collections.emptyList()));
}

/**
Expand Down

1 comment on commit 80fc4a7

@tastybento
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! I was looking at this code last night and I couldn't work out how to fix it at all! I missed the BeforeClass part. Wow. You are a test ninja!

Please sign in to comment.