All Projects → mechero → Spring Boot Testing Strategies

mechero / Spring Boot Testing Strategies

Sample project demonstrating different Test Strategies that can be followed when using Spring Boot.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Spring Boot Testing Strategies

Mastering Junit5
A comprehensive collection of test examples created with JUnit 5
Stars: ✭ 223 (-4.29%)
Mutual labels:  spring-boot, spring, junit
Quickperf
QuickPerf is a testing library for Java to quickly evaluate and improve some performance-related properties
Stars: ✭ 231 (-0.86%)
Mutual labels:  spring-boot, spring, junit
Javastud
Official, Main: This is Core/Advance java example series project. It help to learn java step by step using pdf tutorial provided here and corresponding demo project for the eclipse. Tag: Java Student, Java Stud, Stud Java, StudJava, Java Teachers, Studs Quick Start Guide, Studs Java, Object Oriented Programming, Core Java, Java SE, Java EE, Java Enterprise Edition, Java Blog, Java Articles, Java Web, JSP, Servlet, Maven, Spring, Hibernate, Spring-boot, Spring MVC Web, Angular JS, Angular 2, Java Security, Java CRUD, Java Login Example, File Handling, Multi threading, exception handling, Collection classes, Swing, Database, Date Time, Joda Time, JPA.
Stars: ✭ 220 (-5.58%)
Mutual labels:  spring-boot, spring
Event Driven Spring Boot
Example Application to demo various flavours of handling domain events in Spring Boot
Stars: ✭ 194 (-16.74%)
Mutual labels:  spring-boot, spring
Awesome Spring Boot
springboot 各种资料整理(demo、教程、网站、starter文档等),持续更新,欢迎pr。
Stars: ✭ 198 (-15.02%)
Mutual labels:  spring-boot, spring
Stormpath Sdk Java
Official Java SDK for the Stormpath User Management REST API
Stars: ✭ 221 (-5.15%)
Mutual labels:  spring-boot, spring
Awesome Spring
A curated list of awesome books, tutorials, courses, and resources for the Spring framework ecosystem.
Stars: ✭ 186 (-20.17%)
Mutual labels:  spring-boot, spring
Resteasy Spring Boot
RESTEasy Spring Boot Starter
Stars: ✭ 190 (-18.45%)
Mutual labels:  spring-boot, spring
Ebook
🔥🔥Java相关精品电子书分享100+,书籍来自网络🔥🔥
Stars: ✭ 197 (-15.45%)
Mutual labels:  spring-boot, spring
Sample Zuul Filters
Samples of custom Zuul 1 filters for use in Spring Cloud Netflix
Stars: ✭ 201 (-13.73%)
Mutual labels:  spring-boot, spring
Spring Boot Postgresql Jpa Hibernate Rest Api Demo
Building RESTful APIs with Spring Boot, PostgreSQL, JPA and Hibernate
Stars: ✭ 209 (-10.3%)
Mutual labels:  spring-boot, spring
Jpa Hibernate Tutorials
Hibernate Tutorials with Spring Boot and Spring-Data-JPA
Stars: ✭ 186 (-20.17%)
Mutual labels:  spring-boot, spring
Rxjava Spring Boot Starter
RxJava Spring MVC integration
Stars: ✭ 180 (-22.75%)
Mutual labels:  spring-boot, spring
Myuploader Backend
单文件上传,多文件上传,大文件上传,断点续传,文件秒传,图片上传
Stars: ✭ 177 (-24.03%)
Mutual labels:  spring-boot, spring
Errors Spring Boot Starter
Elegant Error Handling for Spring Boot
Stars: ✭ 209 (-10.3%)
Mutual labels:  spring-boot, spring
Spring Cloud Tutorial
Spring Cloud Tutorial.《Spring Cloud 教程》
Stars: ✭ 173 (-25.75%)
Mutual labels:  spring-boot, spring
Spring And Spring Boot
Lab solutions for Spring and Spring Boot course
Stars: ✭ 163 (-30.04%)
Mutual labels:  spring-boot, spring
Rebuild
Building your business-systems freely! 高度可定制化的企业管理系统 企业中台
Stars: ✭ 169 (-27.47%)
Mutual labels:  spring-boot, spring
Spring Microservice Sample
Spring Boot based Mircoservice sample
Stars: ✭ 199 (-14.59%)
Mutual labels:  spring-boot, spring
Spring Reddit Clone
Reddit clone built using Spring Boot, Spring Security with JPA Authentication, Spring Data JPA with MySQL, Spring MVC. The frontend is built using Angular - You can find the frontend source code here - https://github.com/SaiUpadhyayula/angular-reddit-clone
Stars: ✭ 210 (-9.87%)
Mutual labels:  spring-boot, spring

Spring Boot Testing Strategies

Introduction

This sample application made with Spring Boot is intended to show the different approach for testing, from Unit Tests with MockMVC in Standalone mode to full @SpringBootTest as Integration tests between the modules.

The complete guide is available on The Practical Developer Blog.

The application

The logic behind the application is simple: it's a repository of superheroes that you can access through a REST API. It allows to read the available ones (which are hardcoded when the application starts up) and also add new members to the crew.

The architecture is simple: just the Controller layer (REST) and a SuperHeroRepository. To illustrate the differences when creating tests, there are two extra classes that work at a web layer level:

  • SuperHeroExceptionHandler. It's a ControllerAdvice that will transform a NonExistingHeroException into a 404 NOT_FOUND HTTP error code.
  • SuperHeroFilter. This web filter adds a new header to the HTTP response.

Testing strategies

In the test sources you can find four different approaches to test the Controller. SuperHeroControllerMockMvcStandaloneTest. Uses a MockitoJUnitRunner and it's the most lightweight approach.

MockMVC in Standalone mode

Then you can find two approaches using a Spring context, both use MockMVC and one of them already introduces the @SpringBootTest annotation.

MockMVC using the context

Finally, SuperHeroControllerSpringBootTest shows how to write a @SpringBootTest based test mocking other layers but utilizing the web server with a RestTemplate.

@SpringBootTest using context and web server

To check conclusion and more information please visit the blog.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].