Java 用junit编写一个测试用例

Java 用junit编写一个测试用例,java,junit,junit4,Java,Junit,Junit4,对于这种SetScene方法,用Junit编写测试用例的正确方法是什么 public static void SetScene(int index){ root.getChildren().remove(liste.get(indexcurrent)); root.getChildren().add(liste.get(index)); indexcurrent=index; if (index == 3) { try { root

对于这种SetScene方法,用Junit编写测试用例的正确方法是什么

public static void SetScene(int index){
  root.getChildren().remove(liste.get(indexcurrent));
  root.getChildren().add(liste.get(index));
  indexcurrent=index;


    if (index == 3) {
        try {
            root.setCenter(liste.get(index));
        }
        catch (Exception InvocationTargetException){
            }
        }
    }

我可能会这样做

  • 准备
    根目录
    和子目录
  • 调用
    SetScene(x)
  • 检查
    root
    currentindex
    是否有所需的值和状态

  • 你试过什么了吗?你到底被困在哪里了?没有。实际上我不明白。对不起,我先答错了。然后我改正了。