Why must jUnit's fixtureSetup be static?

前端 未结 8 1505
悲&欢浪女
悲&欢浪女 2020-12-04 07:50

I marked a method with jUnit\'s @BeforeClass annotation, and got this exception saying it must be static. What\'s the rationale? This forces all my init to be on static fiel

8条回答
  •  青春惊慌失措
    2020-12-04 08:56

    To resolve this issue just change the method

    public void setUpBeforeClass 
    

    to

    public static void setUpBeforeClass()
    

    and all that are defined in this method to static.

提交回复
热议问题