title: JUnit @Before vs @Rule
body: <p>I understand that, </p>
  
  <ul>
  <li><code>@Before</code> and <code>@BeforeClass</code> run before each test, or the entire test class, respectively </li>
  <li><code>@Rule</code> and <code>@ClassRule</code> wraps each test, or the entire test class, respectively.</li>
  </ul>
  
  <p>Let's say I need to initialize some data before each test method,</p>
  
  <p><strong>How do I decide between using <code>@Before</code> and <code>@Rule</code>? Under what conditions is one preferred over another?</strong> The same question also goes for <code>@BeforeClass</code> vs.<code>@ClassRule</code>.</p>