Testing tooling

JaCoCo coverage counters

Execution metrics derived from bytecode; not correctness proof. Framework or debugger behavior source-reviewed; actual tool execution NOT RUN.

Formal Syntax & Structure

java syntaxjava
instruction, branch and line counters

Working Example

Example Snippetjava
import java.util.HashMap;import java.util.Map;
public class Main {    interface Catalog { int price(String sku); }    static final class FakeCatalog implements Catalog {        private final Map<String, Integer> prices = new HashMap<>();        void put(String sku, int price) { prices.put(sku, price); }        public int price(String sku) {            Integer price = prices.get(sku);            if (price == null) throw new IllegalArgumentException("unknown SKU");            return price;        }    }    static int total(Catalog catalog, String sku, int count) {        if (count < 0) throw new IllegalArgumentException("negative count");        return Math.multiplyExact(count, catalog.price(sku));    }    public static void main(String[] args) {        FakeCatalog fake = new FakeCatalog();        fake.put("B1", 17);        if (total(fake, "B1", 2) != 34) throw new AssertionError("wrong total");        fake.put("B1", 21);        if (total(fake, "B1", 2) != 42) throw new AssertionError("stale price");        System.out.println("fake checks passed");    }}
Java Reference