Skip to content
Jean Bisutti edited this page Aug 19, 2020 · 30 revisions

🚩 Table of contents

Spring and JUnit 4

Spring and JUnit 5

Spring and TestNG

Spring and JUnit 4

QuickPerfSpringRunner

QuickPerfSpringRunner adds QuickPerf features to SpringRunner (also called SpringJUnit4ClassRunner).

To use it, following your Spring version, you have to add one of the dependencies below.

Spring 5

<dependency>
  <groupId>org.quickperf</groupId>
  <artifactId>quick-perf-junit4-spring5</artifactId>
  <version>1.0.0-RC7</version>
  <scope>test</scope>
</dependency>

Spring 4

<dependency>
  <groupId>org.quickperf</groupId>
  <artifactId>quick-perf-junit4-spring4</artifactId>
  <version>1.0.0-RC7</version>
  <scope>test</scope>
</dependency>

Spring 3

<dependency>
  <groupId>org.quickperf</groupId>
  <artifactId>quick-perf-junit4-spring3</artifactId>
  <version>1.0.0-RC7</version>
  <scope>test</scope>
</dependency>

With one of these dependencies, you have access to core, JVM and SQL annotations.

QuickPerf annotations are executed after the loading of the SpringContext. So, for example, if you profile your JVM with @ProfileJvm, the profiling starts just after the loading of the Spring context.

Java code example with QuickPerfSpringRunner

	import org.junit.runner.RunWith;
	import quickperf.spring.QuickPerfSpringRunner;

	@RunWith(QuickPerfSpringRunner.class)
	public class AccountTest {

	}

Configuration for SQL annotations

Before using SQL annotations, you have to add a QuickPerfProxyBeanPostProcessor bean.
To do this, you can look at the Java code examples below or this Spring Boot project.

After that, you can evaluate the SQL properties of the database repositories, the Spring services or the Spring controller.

Addition of a QuickPerfProxyBeanPostProcessor bean with @Bean

	import org.springframework.context.annotation.Bean;
	import org.springframework.context.annotation.Configuration;
	import org.quickperf.spring.sql.QuickPerfProxyBeanPostProcessor;

	@Configuration
	public class Configs {

		@Bean
		public QuickPerfProxyBeanPostProcessor dataSourceBeanPostProcessor() {
			return new QuickPerfProxyBeanPostProcessor();
		}

	}

Addition of a QuickPerfProxyBeanPostProcessor bean in a Spring XML file

<bean id="QuickPerfProxyBeanPostProcessor" class = "org.quickperf.spring.sql.QuickPerfProxyBeanPostProcessor" />

Project example with Spring Boot and JUnit 4

See the code of this repository.

Spring and JUnit 5

Configure your project for QuickPerf JUnit 5

Please follow the instructions described in this page to can use JVM and core annotations.

See the instructions described below to be able to use SQL annotations.

Configure your project to use SQL annotations

You have to add the following dependency:

        <dependency>
            <groupId>org.quickperf</groupId>
            <artifactId>quick-perf-sql-spring5</artifactId>
            <scope>test</scope>
        </dependency>

To can use SQL annotations, you have to add a QuickPerfProxyBeanPostProcessor bean.
To do this, you can look at the code examples below or this Spring Boot project.

After that, you can evaluate the SQL properties of the database repositories, the Spring services or the Spring controller.

Addition of a QuickPerfProxyBeanPostProcessor bean with @Bean

        import org.quickperf.spring.sql.QuickPerfProxyBeanPostProcessor;
        import org.springframework.context.annotation.Bean;
        import org.springframework.context.annotation.Configuration;

        @Configuration
	public class Configs {

		@Bean
		public QuickPerfProxyBeanPostProcessor dataSourceBeanPostProcessor() {
			return new QuickPerfProxyBeanPostProcessor();
		}

	}

Project example with Spring Boot and JUnit 5

See the code of this repository.

Spring and TestNG

You can't yet use QuickPerf annotations when Spring is used together with TestNG. If you are interested by this feature, you can help us to develop it. Don't hesitate to leave a comment on this issue.

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