title: Is Assert-ing on tearDown (@After) method wrong?
body: <p>I have multiple test cases even and if the logic is different, the output must be equal on all of them. So I was thinking in how to generalize them and place the Assert method only once.</p>
  
  <p>Is there any way better to do it than this one:</p>
  
  <pre><code>static public class Tests() {
  
      private static String expected = null;
      private String actual = null;
  
      @BeforeClass
      public static void setUpBeforeClass() throws Exception {
          expected = new String("My Desired Output");
      }
  
      @Before
      public void setUp() {
          actual = new String();
      }
  
      @Test
      public void test1() throws Exception {
          actual = ...
      }
  
      @Test
      public void test2() throws Exception {
          actual = ...
      }
  
      @After
      public void tearDown() throws Exception {
          assertThat(actual, is(equalTo(expected)));
      }
  
      @AfterClass
      public static void tearDownAfterClass() {
      }
  }
  </code></pre>
  
  <p>Running method:</p>
  
  <pre><code>@Test
  public void runTests() {
      Result result = JUnitCore.runClasses(Tests.class);
      assertThat(result.getRunCount(), is(2));
      assertThat(result.getFailureCount(), is(0));
  }
  </code></pre>