Bahmni Core: how to run a single integration test with Maven?

Hi Bahmni team,

(Q1.) How do you do that in Bahmni Core? Sorry in advance if that’s an obvious Maven question. Usually I would do this:

mvn -Dtest=MyTestIT test

But this doesn’t actually launch the IT, nor does this:

mvn -Dtest=MyTestIT -P IT test

Any idea?

(Q2.) Also what’s the purpose of BaseIntegrationTest? I can see that it leverages TestingApplicationContext.xml, but BaseModuleContextSensitiveTest does it upstream already. Also why does it inherit BaseModuleWebContextSensitiveTest since those are API tests?

1 Like

Anyone? Cc: @angshuonline @gsluthra

@mksd, depends on the error you were getting here, but while trying a similar thing on the Reporting module, I could make this work by either:

  • using the -DfailIfNoTests=false argument, or
  • checking out the sub directory in which you want to run your tests. And run your command from there. cd bahmnicore-api for instance.

This is because if you force to run only an individual test of a given sub-module (for instance bahmnicore-api) but from the main module directory, then other sub-modules will be build as well but won’t have any tests to run and therefore fail. So using -DfailIfNoTests=false will solve this situation. Otherwise, run your tests directly from the sub-module directory.

for instance:

cd bahmnicore-api/
mvn -Dtest=EpisodeEncounterCreateCommandIT test
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.bahmni.module.bahmnicore.encounterTransaction.command.EpisodeEncounterCreateCommandIT
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 15.973 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.192 s
[INFO] Finished at: 2017-08-18T11:41:52+07:00
[INFO] Final Memory: 23M/298M
[INFO] ------------------------------------------------------------------------
1 Like

This is the best and latest method that I have found so far (also works very well with any test in REST WS):

Example with BahmniPatientDaoImplIT:

mvn test -P IT -Dtest=BahmniPatientDaoImplIT -pl bahmnicore-api/

Credits to Nick Gemer for his answer: ‘maven :: run only single test in multi-module project’.