Does TestNG support something like JUnit4's @Rule?

前端 未结 2 1126
长发绾君心
长发绾君心 2020-12-15 03:29

Does TestNG have something like @Rule? I am thinking specifically about:

@Rule public TemporaryFolder folder = ...

Or even

2条回答
  •  半阙折子戏
    2020-12-15 04:24

    BeforeClass/AfterClass of TestNG can simulate something like the rule/ruleClass of JUnit, but there are some functions and effects that these classes cannot replicate, such as: repeat, filter, etc.

    However, there are some interfaces provided by TestNG that could be used to simulate these functions instead, e.g. IAnnotationTransformer, IMethodInterceptor.

提交回复
热议问题