Skip to content

Demo Spring Boot project with JUnit 5 Tests. It includes integration test (for controller) and unit tests (for service and simple class).

Notifications You must be signed in to change notification settings

carlosCharz/springbootjunit5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JUnit 5 Tests in Spring Boot project

Demo Spring Boot project with JUnit 5 Tests. It includes integration test (for controller) and unit tests (for service and simple class).

Technologies

  1. Spring Boot (spring-boot-starter-web, spring-boot-starter-tomcat, spring-boot-starter-test)
  2. Java 8
  3. Tomcat 8.5.x
  4. Maven
  5. JUnit 5

Architecture

  1. Controller: is the presentation layer where the end points are located
  2. Service: is the service layer where the business logic resides
  3. Repository: is the persistence layer where the CRUD repository is located

Tests

  1. Integration Test (for the Controller): it uses mockMvc and Hamcrest matchers
  2. Unit Test (for the Service): it uses the Mockito framework
  3. Unit Test (for a simple class) it uses pure JUnit

Exposed methods

1. Get user by id. HTTP Method: GET

http://localhost:8080/springbootjunit5/users/1

2. Create a user. HTTP Method: POST

http://localhost:8080/springbootjunit5/users
{
  "name": "Carlos",
  "age": 29,
  "email": "[email protected]"
}

Documentation and Examples

About me

I am Carlos Becerra - MSc. Softwware & Systems. But to tell you the truth, I'd prefer to be a passionate developer. You can contact me via:

Any improvement or comment about the project is always welcome! As well as others shared their code publicly I want to share mine! Thanks!

License

Copyright 2020 Carlos Becerra

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

About

Demo Spring Boot project with JUnit 5 Tests. It includes integration test (for controller) and unit tests (for service and simple class).

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages