### Question:
HeapDumper { public static void dumpHeap(String fileName) { dumpHeap(false, fileName); } private  HeapDumper(); static void dumpHeap(String fileName); static void dumpHeapWithOnlyLiveObjects(String fileName);  }### Answer:
@Test public void should_dump_heap() { Path targetDirectory = Paths.get("target"); String targetPath = targetDirectory.toFile().getAbsolutePath(); String heapDumpPath = targetPath + File.separator + "heap-dump-test.hprof"; File heapDumpFile = new File(heapDumpPath); if(heapDumpFile.exists()) { heapDumpFile.delete(); } HeapDumper.dumpHeap(heapDumpPath); assertThat(heapDumpFile).exists(); }