Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Adding link to Unit Tests page, info I was looking for was there. There seem to be more links to this page, but less info on it. Maybe these two pages should be consolidated as part of cleanup?

...

If you use the Maven archetype to create your module, see this. If you are using an older mavenized or unmavenized module, see this.

...

The two dependencies should be placed in the modue (api/omod) pom files for openmrs platform 1.11.x, may not need to update the parent pom file

 


Create Your Test

Code Block
package org.openmrs.module.yourmodule;
/**
* Tests the MyModuleService class and all of its methods
*
**/
public class MyModuleServiceTest extends BaseModuleContextSensitiveTest {

/**
* Make sure that MyService runs fine with a null
* parameter to getMyModuleObject
*
* @throws Exception
*/
@Test
public void shouldGetMyModuleObjectWithNullParameter() throws Exception {
     MyModuleService service = Context.getService(MyModuleService.class));
     MyModuleObject obj = service.getMyModuleByName(null);
     Assert.assertNull(output);
 }
}

...

(When running unit tests in Eclipse) Make sure that you are using Spring 2.5 or above. You can also addsetDependencyCheck(false) to the constructor of your test class.

Related Links

Unit Tests