开发者

How to prepare state for several JUnit tests only once

开发者 https://www.devze.com 2023-02-03 23:35 出处:网络
I need to test a program that first preprocesses some data and then computes several different results using this preprocessed data -- it makes sense to开发者_如何学JAVA write separate test for each c

I need to test a program that first preprocesses some data and then computes several different results using this preprocessed data -- it makes sense to开发者_如何学JAVA write separate test for each computation.

Official JUnit policy seems to be that I should run preprocessing before each computation test. How can I set up my test so that I could run the preparation only once (it's quite slow) before running remaining tests?


Use the annotation @BeforeClass to annotate the method which will be run once before all test methods.

0

精彩评论

暂无评论...
验证码 换一张
取 消