How to prepare state for several JUnit tests only once

I need to test a program that first preprocesses some data and then calculates several different results using these preprocessed data - it makes sense to write a separate test for each calculation.

JUnit's official policy seems to be that I have to do preprocessing before each calculation test. How do I set up my test so that I can run the preparation only once (rather slowly) before running the remaining tests?

+4
source share
1 answer

Use the @BeforeClass annotation to annotate a method that will run once before all testing methods.

+13
source

Source: https://habr.com/ru/post/1334958/


All Articles