Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • It is annotated with @Configuration.
  • @ComonentScan tells Spring which components should be loaded.  Note that Spring notes all classes in the package of the class specified so it can load too many classes.  To avoid this, specify the includeFilters as in the example above and useDefaultFilters=false in the @ComponentScan annotation.  What this does is makes sure only the classes specified in @ComponentScan is loaded and not other classes in the same package.
  • Extend SpringUtils.CloudStackConfiguration to get all the transaction handling etc.
  • Use Mockito to mock up the components that you don't want to test.
  • Specify the Library if you used includeFilters in the @ComponentScan annotation.  Just copy this class into your TestConfiguration.  Make sure the class is public static.

 

Besides these, if your unit tested class involves methods of the method you need to unit test has @DB annotation, then you also need to make the following changes:

...