EMR-API OMOD module tests aren't being run

I’ve been working on adding some new tests to EmrEncounterController_1_111_Test (while working on EA-90). When I tried to run the EmrEncounterController tests via junit/Intellij I got various application context errors.

Rather than trying to debug, I simply ran “mvn clean install” to execute the tests via maven. When (after adding my new tests) “mvn clean install” passed without error I was suspicious (tests never pass the first time!). I probed deeper and confirmed that none of the tests in the OMOD project were being executed via a simple “mvn clean install”.

So I logged on to OpenMRS CI to see if there way a special maven profile / flag used to execute the omod tests, but OpenMRS CI seemed only be running a simple “mvn deploy”. In fact, it looks like the CI plan is not executing the tests in the omod directory… looking at the mvn logs from CI for the omod module I see:

20-Jan-2016 19:58:34	
20-Jan-2016 19:58:34	-------------------------------------------------------
20-Jan-2016 19:58:34	 T E S T S
20-Jan-2016 19:58:34	-------------------------------------------------------
20-Jan-2016 19:58:34	There are no tests to run.
20-Jan-2016 19:58:34	
20-Jan-2016 19:58:34	Results :

Done anyone know the proper way to execute these tests (and can we modify CI to make sure it execute them)?

That test was given a name different from the expected one, according to the 1.11 profile in the pom. Just renamed it at

https://github.com/openmrs/openmrs-module-emrapi/commit/78451a1c160bdb528360a0dd70e7d87a127c6070

Was that just a cosmetic fix, or will that trigger it to be run?

The 1.11 profile expected tests to end with “1_11_Test.java”, but this was ending with “1_111_Test.java” Made a follow up commit for the tests which have been failing but un noticed at

https://github.com/openmrs/openmrs-module-emrapi/commit/601f88f056a948b39fa2b5b5c0f65d8a1ba5c459

1 Like

Awesome, thanks @dkayiwa!

Actually, it looks like EmrEncounterController_1_10_Test stil isn’t running… nor is PatientProfileResource_1_9_Test.

Do we need to do something to get these to run? Or do they only run when specifically setting a 1.10 or 1.9 context?

Thanks! Mark

These will run when you specifically supply their profiles as -PMRS1.10 or -PMRS1.9 I see the 1.10 and 1.11 profiles set active. But since only one should be, the 1.11 wins because it is declared last.

The tests for 1.9 and 1.10 profiles are failing, i guess because no one was aware of this. You are the whistle blower! :smile:

That pom file has all profiles activated by default, the last ones wins which is the1.11 profile, so no tests were running before because the Test class didn’t match that pattern of the inclusions as Daniel pointed out. Maven can only run the tests against a single profile which in this case it defaults to 1.11, to run the other tests you need to specify the profile that matches them as Daniel mentions. Looks like you need a different stage for each profile in the CI plan to have all the tests run for each build

We are trying to add some functionality for PatientProfileResource and have just discovered that PatientProfileResource_1_9_Test tests are all failing. Has anything been done about this? We need to submit a pull request with this functionality.

@abishek.anand can you try again now?

They are still failing

Did you remember to pull the latest changes?

Yes i pulled latest changes. Even on the openmrs ci i can’t see those tests running.

After pulling latest changes i am also getting this error while doing mvn clean install.

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.openmrs:event-api-1.x:jar is missing. @ line 103, column 21
[ERROR] 'dependencies.dependency.version' for org.openmrs:event-api-2.x:jar is missing. @ line 109, column 21

Can you try again now?

Those dependency errors are fixed but when i run mvn clean install the tests PatientProfileResource_1_9_Test tests are still not running. When i run the test explicitly by running mvn -Dtest=PatientProfileResource_1_9_Test test, the tests fail with these stack traces:

<testcase time="15.423" classname="org.openmrs.module.emrapi.rest.resource.PatientProfileResource_1_9_Test" name="shouldCreatePatient">
    <error message="The person does not exist." type="org.openmrs.module.webservices.rest.web.response.ConversionException">org.openmrs.module.webservices.rest.web.response.ConversionException: The person does not exist.
	at org.openmrs.module.emrapi.rest.resource.PatientProfileResource.getPersonFromUuid(PatientProfileResource.java:160)
	at org.openmrs.module.emrapi.rest.resource.PatientProfileResource.getPerson(PatientProfileResource.java:152)
	at org.openmrs.module.emrapi.rest.resource.PatientProfileResource.createRelationship(PatientProfileResource.java:132)
	at org.openmrs.module.emrapi.rest.resource.PatientProfileResource.getRelationships(PatientProfileResource.java:100)
	at org.openmrs.module.emrapi.rest.resource.PatientProfileResource.create(PatientProfileResource.java:84)
	at org.openmrs.module.emrapi.rest.resource.PatientProfileResource_1_9_Test.shouldCreatePatient(PatientProfileResource_1_9_Test.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:103)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
</error>
  </testcase>
  <testcase time="0.057" classname="org.openmrs.module.emrapi.rest.resource.PatientProfileResource_1_9_Test" name="shouldUpdatePatient">
    <error type="java.lang.NullPointerException">java.lang.NullPointerException
	at org.openmrs.module.emrapi.rest.resource.PatientProfileResource.getRelationships(PatientProfileResource.java:96)
	at org.openmrs.module.emrapi.rest.resource.PatientProfileResource.update(PatientProfileResource.java:198)
	at org.openmrs.module.emrapi.rest.resource.PatientProfileResource_1_9_Test.shouldUpdatePatient(PatientProfileResource_1_9_Test.java:52)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:103)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
</error>
  </testcase>