quick-perf / quickperf

QuickPerf is a testing library for Java to quickly evaluate and improve some performance-related properties
https://github.com/quick-perf/doc/wiki/QuickPerf
Apache License 2.0
465 stars 67 forks source link

Issue with hierarchy of unit-tests classes #191

Open blacelle opened 1 year ago

blacelle commented 1 year ago

Describe the bug I consider some tests based on an abstract method:

@RunWith(QuickPerfJUnitRunner.class)
public abstract class ATest {

    protected abstract void benchMe();

    @MeasureHeapAllocation
    @Test
    public void testHeapAllocation() {
        benchMe();
    }
}

and the implementation in a sub-class:

@RunWith(QuickPerfJUnitRunner.class)
public class Test extends ATest {

    @Override
    protected void benchMe() {
        // empty
    }
}

Expected behavior Run smoothly

Actual behavior

It fails with:

    at org.quickperf.issue.PerfIssuesEvaluator.evaluatePerfIssuesIfNoJvmIssue(PerfIssuesEvaluator.java:45)
    at org.quickperf.junit4.MainJvmAfterJUnitStatement.evaluate(MainJvmAfterJUnitStatement.java:62)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.IllegalStateException: java.io.FileNotFoundException: /var/folders/8b/p64c8tfs4d7gf3v8tcmwbz580000gn/T/QuickPerf-521872497461803058/allocation.ser (No such file or directory)
    at org.quickperf.repository.ObjectInputStreamBuilder.buildFileInputStream(ObjectInputStreamBuilder.java:46)
    at org.quickperf.repository.ObjectInputStreamBuilder.buildObjectInputStream(ObjectInputStreamBuilder.java:28)
    at org.quickperf.repository.LongFileRepository.retrieveLongValueFromFile(LongFileRepository.java:42)
    at org.quickperf.repository.LongFileRepository.find(LongFileRepository.java:37)
    at org.quickperf.jvm.allocation.AllocationRepository.findAllocation(AllocationRepository.java:32)
    at org.quickperf.jvm.allocation.bytewatcher.ByteWatcherRecorder.findRecord(ByteWatcherRecorder.java:45)
    at org.quickperf.jvm.allocation.bytewatcher.ByteWatcherRecorder.findRecord(ByteWatcherRecorder.java:19)
    at org.quickperf.issue.PerfIssuesEvaluator.findPerfRecord(PerfIssuesEvaluator.java:91)
    at org.quickperf.issue.PerfIssuesEvaluator.buildPerfRecordByAnnotation(PerfIssuesEvaluator.java:81)
    at org.quickperf.issue.PerfIssuesEvaluator.evaluatePerfIssuesIfNoJvmIssueWithPotentialUnexpectedException(PerfIssuesEvaluator.java:59)
    at org.quickperf.issue.PerfIssuesEvaluator.evaluatePerfIssuesIfNoJvmIssue(PerfIssuesEvaluator.java:38)
    ... 19 more
    Suppressed: java.lang.InstantiationException
Caused by: java.io.FileNotFoundException: /var/folders/8b/p64c8tfs4d7gf3v8tcmwbz580000gn/T/QuickPerf-521872497461803058/allocation.ser (No such file or directory)
    at java.base/java.io.FileInputStream.open0(Native Method)
    at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
    at org.quickperf.repository.ObjectInputStreamBuilder.buildFileInputStream(ObjectInputStreamBuilder.java:44)
    ... 29 more

To Reproduce (Please provide a link to a live example or steps to reproduce this behavior.)

Versions