Skip to content
Jean Bisutti edited this page Jul 15, 2019 · 30 revisions

Outline

QuickPerfSpringRunner

Configuration for SQL annotations

Spring Boot examples

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-RC2</version>
  <scope>test</scope>
</dependency>

Spring 4

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

Spring 3

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

With one of these dependencies, you have access to JVM annotations 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

To can use SQL annotations, you have to supply an instance of QuickPerfProxyBeanPostProcessor to your spring context.
To do this, you can look at the Java code examples below or in this Spring Boot project.

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

Java code examples with QuickPerfSpringRunner and a SQL annotation

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

	@Configuration
	public class Configs {

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

	}
	import quickperf.spring.QuickPerfProxyBeanPostProcessor;
        import quickperf.spring.QuickPerfSpringRunner;
	
         @SpringBootTest(classes = {FootballApplication.class}
                       , webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
         )
	public class PlayerControllerTest {

           @ExpectSelect(1)
           @HeapSize(value = 50, unit = AllocationUnit.MEGA_BYTE)
           @Test
           public void should_find_all_players() {

	   }

       }

Spring Boot examples

See the code of this repository.

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