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