Generating JUnit stubs for new methods in existing class in Eclipse

前端 未结 3 1415
难免孤独
难免孤独 2021-02-05 05:55

This question is tangentially related to How can I create JUnit stub methods in eclipse? but it doesn\'t answer my specific question.

Assuming you have an existing JUnit

3条回答
  •  半阙折子戏
    2021-02-05 06:26

    The usual working cycle with unit tests is to create the test case first

    public void test_new_method() {
        ClassUnderTest x = new ClassUnderTest();
        x.NewMethod();
    }
    

    At that point Eclipse will give you a warning that the method "NewMethod" does not exist. Than you simply select a "Quick Fix" (Ctrl-1 or Ctrl-2 i'm not sure) to create the missing method in the class.

提交回复
热议问题