@AnalyzeSql - quick-perf/doc GitHub Wiki

The AnalyzeSql annotation builds an analysis report of the SQL executed during the test method execution.

Displayed information is:

  • Number of total JDBC executions,
  • Longest execution time of all JDBC executions,
  • Number of queries for each type (CRUD). Please note that PLSQL like statements will not be counted.
  • Alerts and or hints regarding queries syntax (usage of wildcards in select statements, N + 1 one issue etc ... See the global annotations.
  • Sql queries.

This annotation accepts a Writer class (must implement WriterFactory interface) to allow writing to the desired output. See example below for file export.

   // Helper class used to return a Writer class
   public static class FileWriterBuilder implements WriterFactory {
 
      @Override
      public Writer buildWriter() throws IOException {
          return new FileWriter(desired-path-to-exported-file);
      }
   }
 
   // annotated test method
   @AnalyzeSql(writerFactory = FileWriterBuilder.class)
   public void select() {
           ...
       };
   }