Skip to content

@AnalyzeSql

Jean Bisutti edited this page Sep 29, 2021 Β· 1 revision

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() {
           ...
       };
   }

Annotations

πŸ‘‰  Core

πŸ‘‰  JVM

πŸ‘‰  SQL

πŸ‘‰  Scopes

πŸ‘‰  Create an annotation

Supported frameworks

πŸ‘‰  JUnit 4

πŸ‘‰  JUnit 5

πŸ‘‰  TestNG

πŸ‘‰  Spring

How to

πŸ‘‰  Detect and fix N+1 SELECT

Project examples

πŸ‘‰  Maven performance

πŸ‘‰  Spring Boot - JUnit 4

πŸ‘‰  Spring Boot - JUnit 5

πŸ‘‰  Micronaut Data - JUnit 5

πŸ‘‰  Micronaut - Spring - JUnit 5

πŸ‘‰  Quarkus - JUnit 5

Miscellaneous

πŸ‘‰  FAQ

πŸ‘‰  QuickPerf code

Clone this wiki locally