title: assertEquals, what is actual and what is expected?
body: <p>I always wondered what exactly is the meaning of actual and expected in <code>assertEquals</code> in libraries like TestNG.</p>
  
  <p>If we read the Java Docs we see:</p>
  
  <pre><code>public static void assertEquals(... actual, ... expected)
  Parameters:
      actual - the actual value
      expected - the expected value
  </code></pre>
  
  <p>From my understanding the <code>expected</code> value is the known one, so the one we expect, and the <code>actual</code> one is the one we want to verify. For example, assume we want to test a function <code>fooBar</code> that always has to return <code>56</code>.</p>
  
  <p>In such a case I would do: <code>assertEquals(sth.fooBar(), 56)</code>. But with a quick search on <a href="https://github.com/search?l=java&amp;q=assertEquals&amp;ref=simplesearch&amp;type=Code&amp;utf8=%E2%9C%93" rel="noreferrer">GitHub</a> it seems people do it the other way around, so <code>assertEquals(56, sth.fooBar())</code>. But how can the expected value be <code>sth.fooBar()</code> when we don't even know that value? It seems that <code>sth.fooBar()</code> is the actual value which we compare against the expected which we already know.</p>
  
  <p>I know there is no difference of the correctness of a test but I would like to follow the "correct" way.</p>