@BeforeAll Method as non-static

后端 未结 2 705
谎友^
谎友^ 2021-02-13 15:31

I was able to implement a non-static setup method with @BeforeAll annotation. It seems to be working correctly as only gets call once. I am bit confuse as the doc

相关标签:
2条回答
  • 2021-02-13 15:41

    You simply need to annotate your test class (that contains the @BeforeAll method) with the snippet below and you'll be good to go.

    @TestInstance(Lifecycle.PER_CLASS)
    
    0 讨论(0)
  • 2021-02-13 15:50

    If you want use non-static @BeforeAll and @AfterAll methods you should change test instance lifecycle to per_class.

    Look there: 2.10. Test Instance Lifecycle

    0 讨论(0)
提交回复
热议问题