title: JUnit testing System.err.print()
body: <p>I have a simple array class with some methods such as <code>Add(int n)</code>, <code>AddAt(int n, int index)</code>, etc.</p>
  
  <p>the addAt method calls another method from super class </p>
  
  <pre><code>public void addAt(int n, int index) {
      if (checkIndex(index, size + 1)){
          ...
      }
  }
  </code></pre>
  
  <p>that checks if the inserted index is not out-bounded, if so the super class method prints an error message to console.</p>
  
  <p>how should I test that if the message is printed? I am using JUnit4.12-beta </p>