title: java coverage is 0% with Junit & Jacoco from the command line
body: <p>I used only 'command line' in all of these processes and I want to do that.(not using Ant, maven, gradle, etc.)</p>
  
  <p>I would like to run Junit test case and JaCoCo coverage estimation.</p>
  
  <p>First, below is my code</p>
  
  <p><code>Calculator.java</code>:</p>
  
  <pre><code>public class Calculator {
    public int evaluate(String expression) {
  
      int sum = 0;
      for(String summand: expression.split("\\+"))
          sum += Integer.valueOf(summand);
      System.out.println("Hello World!!");
      return sum;
    }
  }
  </code></pre>
  
  <p><code>CalculatorTest.java</code>:</p>
  
  <pre><code>import static org.junit.Assert.assertEquals;
  import org.junit.Test;
  
  public class CalculatorTest {
    @Test
    public void evaluatesExpression(){
      Calculator calculator = new Calculator();
      int sum = calculator.evaluate("1+2+3");
      assertEquals(6, sum);
    }
  }
  </code></pre>
  
  <p>2 java files are in <code>C\Cal</code> and <code>Cal</code> folder contains 4 jar files
  (<code>junit-4.12.jar</code>, <code>hamcrest-core-1.3.jar</code>, <code>jacococli.jar</code>, <code>jacocoagent.jar</code>)</p>
  
  <p>In this situation, I maked classfile <code>Calculator.class</code>.</p>
  
  <pre><code>javac Calculator.java
  </code></pre>
  
  <p>And then, I maked <code>exec</code> (I think it is execution file of jacoco) file to estimate unit-test coverage of <code>Calculator.java</code> file.</p>
  
  <pre><code>java -javaagent:jacocoagent.jar=destfile=jacoco.exec
  </code></pre>
  
  <p>After that, I extracted the report using the <code>exec</code> file and command</p>
  
  <pre><code>java -jar jacococli.jar report jacoco.exec --classfiles Calculator.class --html "report" --name jacocoReport --sourcefiles "Calulator.java"
  </code></pre>
  
  <p>However, the test coverage in the html report I made was 0%.</p>
  
  <p>Here is my questions:</p>
  
  <ol>
  <li><p>Do you know why my coverage is 0%?</p></li>
  <li><p>Is there any problem in trying to extract the coverage result I want?</p></li>
  <li><p>When calculating the coverage of the <code>Calculator.java</code> file by <code>CalculatorTest.java</code> code and extracting the report, is it correct to write <code>--classfiles</code> only using <code>Calculator.class</code>?</p></li>
  <li><p>There is no difference in the results even if you insert both <code>Calculator.java</code> and <code>CalculatorTest.java</code> in <code>--sourcefiles</code>. Did I put it wrong? Or what is the effect of <code>--sourcefiles</code>?</p></li>
  </ol>
  
  <p>And this is the Internet pages I referenced:</p>
  
  <ul>
  <li><a href="https://github.com/junit-team/junit4/wiki/Getting-started" rel="nofollow noreferrer">https://github.com/junit-team/junit4/wiki/Getting-started</a></li>
  <li><a href="https://stackoverflow.com/questions/40810496/jacoco-report-in-command-line">Jacoco report in command line</a></li>
  </ul>