Book Image

Building Web Apps with Spring 5 and Angular

By : Ajitesh Kumar Shukla
Book Image

Building Web Apps with Spring 5 and Angular

By: Ajitesh Kumar Shukla

Overview of this book

Spring is the most popular application development framework being adopted by millions of developers around the world to create high performing, easily testable, reusable code. Its lightweight nature and extensibility helps you write robust and highly-scalable server-side web applications. Coupled with the power and efficiency of Angular, creating web applications has never been easier. If you want build end-to-end modern web application using Spring and Angular, then this book is for you. The book directly heads to show you how to create the backend with Spring, showing you how to configure the Spring MVC and handle Web requests. It will take you through the key aspects such as building REST API endpoints, using Hibernate, working with Junit 5 etc. Once you have secured and tested the backend, we will go ahead and start working on the front end with Angular. You will learn about fundamentals of Angular and Typescript and create an SPA using components, routing etc. Finally, you will see how to integrate both the applications with REST protocol and deploy the application using tools such as Jenkins and Docker.
Table of Contents (18 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Introduction to unit testing


Unit testing is defined as testing a block of code in isolation. A class can have multiple methods. And, thus, there could be multiple unit tests for a class. The following are some of the best practices that need to be followed when working with unit tests:

  • Refactor code: A method that is long and complex enough, or rather, does multiple things, or has multiple responsibilities that need to be refactored. In other words, a method with a very high cyclomatic complexity would need to be refactored to small methods that conform to the single responsibility principle (a block of code will have just one reason to change).
  • Using test doubles: As the unit tests are about testing a block of code in isolation, any dependencies from the code would need to be mocked. In other words, it will be necessary to make use of test doubles instead of actual service or components when writing unit tests. This can be achieved using some of the following concepts related to mocking...