Versions Compared

Key

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

In CloudStack 4.1 , we has switched over to using Spring for component injection and aop.  This makes it much more flexible in terms of working with Junit.  This page details how to write a test.  This assumes you're already familiar with JUnit.

Testunmigrated-wiki-markup

If the JUnit test you created is testing a component that requires component injection, you should add the following to the top of the class.  Replace the \[configuration.xml\] with the xml that you want to use to configure the components for your test.

Code Block
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locationsloader = "classpath:/[configuration.xml]"AnnotationConfigContextLoader.class)

Within the class, you should add this method.  This call makes sure all of the components injected went through the proper life cycle initialization before the test happens.

...