这是quitAction.java文件 我需要为它创建一个测试文件。
\s*
这是我的测试。我的理解是只要action.execute运行就没问题,因为/ quit命令不需要任何参数,所以不需要覆盖。
/* $Id$ */
/***************************************************************************
* (C) Copyright 2003-2010 - Stendhal *
***************************************************************************
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
package games.stendhal.client.actions;
import games.stendhal.client.gui.j2DClient;
/**
* Quit the client.
*/
class QuitAction implements SlashAction {
/**
* Execute a chat command.
*
* @param params
* The formal parameters.
* @param remainder
* Line content after parameters.
*
* @return <code>true</code> if was handled.
*/
@Override
public boolean execute(final String[] params, final String remainder) {
j2DClient client = j2DClient.get();
if (client != null) {
client.requestQuit();
} else {
System.exit(0);
}
return true;
}
/**
* Get the maximum number of formal parameters.
*
* @return The parameter count.
*/
@Override
public int getMaximumParameters() {
return 0;
}
/**
* Get the minimum number of formal parameters.
*
* @return The parameter count.
*/
@Override
public int getMinimumParameters() {
return 0;
}
}
但是当我运行junit测试时,它会在testExecute()处停止,我不知道为什么。 当然testGetMinimumParameters()和testGetMaximumParameters()都可以。