The code marked @Before will be executed before each test. This is useful for writing many tests that need similar objects or need to run similar code before they run.
accepted
The code marked @Before is executed before each test, while @BeforeClass runs once before the entire test fixture. If your test class has ten tests, @Before code will be executed ten times, but @BeforeClass will be executed only once.
If you only need setup once, you use @BeforeClass when multiple tests need to share the same computationally expensive setup code. You can move code from @BeforeClass into @Before, but your test run may take longer. Note that the code marked @BeforeClass is run as static initializer, therefore it will run before the class instance of your test fixture is created.