我写了一个程序,现在我需要编写一个“可运行的测试脚本”来测试它。测试程序java
我想可运行测试脚本是指主要方法。
但该程序的所有方法调用是触发时鼠标从OptionPane
单击按钮,或输入。 那么,我该如何编写一个可运行的测试脚本来控制鼠标点击?
我不知道我是否有清楚的说明问题。该程序是一个项目任务管理工具,因此您可以单击按钮来创建新项目,保存项目,添加任务,添加工作人员等。问题是我如何控制哪个按钮被java代码点击?
这里是一个一个按钮被点击时调用方法:
public void newProject() {
if (currentProject == null || showConfirm(
"The current progress will not be saved.\nContinue?")) {
resetCurrentProject();
//Get the name of the new project
String name = JOptionPane.showInputDialog(this,
"Please give a name to the project", "New Project",
JOptionPane.QUESTION_MESSAGE);
if (name != null) {
//Initialize the a new project
ArrayList<Task> taskList = new ArrayList<Task>();
ArrayList<Staff> staffList = new ArrayList<Staff>();
//Create a new Project instance
try {
currentProject = new Project(name, staffList, taskList);
} catch (Exception e1) {
showError(e1.getMessage());
}
//Update the project information panel
updateProjectInfoPane();
}
}
}
你不控制鼠标,你到了按钮的引用,并触发一些“点击”的代码-event。 – Alxandr
如何点击点击事件? – xiaofan2406
JOptionPane的输入怎么样? – xiaofan2406