Book Image

Mockito for Spring

By : Sujoy Acharya
Book Image

Mockito for Spring

By: Sujoy Acharya

Overview of this book

Table of Contents (12 chapters)
Mockito for Spring
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with annotations


The Spring Framework provides a set of Spring-specific annotations for unit and integration tests in conjunction with the TestContext framework. The following are widely used annotations:

  • @ContextConfiguration: We have already covered this annotation and loaded applicationContext for integration tests. This annotation is used to determine how to load and configure an ApplicationContext for integration tests. @ContextConfiguration declares the application context's resource locations or the annotated classes that will be used to load the context.

  • @WebAppConfiguration: This class-level annotation is used to instruct the Spring context that the ApplicationContext loaded using the @ContextConfiguration annotation is a WebApplicationContext. We will use WebApplicationContext in the next section.

  • @ContextHierarchy: This is a class-level annotation that loads the parent-child application context in hierarchical order. The following integration test declares a context hierarchy...