parttimenerd / intellij-profiler-plugin

IntelliJ plugin to view JFR profiler files and to profile using JFR
Other
51 stars 4 forks source link

Profiling JUnit tests #29

Open lglauer opened 5 months ago

lglauer commented 5 months ago

Describe the bug Profiling a test run configuration in IntelliJ does not seem to work. All test cases are being executed after starting a test run configuration with "Profile with async-profiler", but no profile.jfr is created and thus no results are shown.

"Profile with JFR" is not available for test run configurations.

To Reproduce Steps to reproduce the behavior:

  1. Rightclick a JUnit5 test class
  2. Choose "Profile with async-profiler ..."
  3. Test case is executed
  4. No profile.jfr is created nor results are shown

Expected behavior Executing a test run configuration (without main method) creates a profile.jfr and shows results.

Workaround I found a workaround by creating a test launcher class with a main method. Running "Profile with async-profiler" on the TestLauncher creates a profile.jfr and shows results as expected.

// Junit5 test launcher
public class TestLauncher {
    public static void main(final String... args) {
        LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
                .selectors(selectPackage("<app>"))
                .filters(includeClassNamePatterns(".*Test"))
                .build();
        Launcher launcher = LauncherFactory.create();
        launcher.execute(request);
    }
}
parttimenerd commented 5 months ago

Thank you for reporting this bug, I'll take a lot next week and hope to fix it soon.