JUnit test fails with Maven but not in Eclipse

Hello,

I’ve been working on the issue https://issues.openmrs.org/browse/TRUNK-5027 and wanted to finish up my work by testing with mvn clean install. I encountered an error in a test I didn’t think was connected to my work at all.

What I got was : ConceptValidatorTest.validate_shouldPassIfDifferentConceptsHaveTheSameShortNames:479 expected:<1> but was:<0>

I didn’t understand how this occurs, so I decided to go into eclipse, set a breakpoint and step through this test. It turns out that it doesn’t fail when running ConceptValidatorTest just from Eclipse.

On stackoverflow I found some suggestions (https://stackoverflow.com/questions/3365628/junit-tests-pass-in-eclipse-but-fail-in-maven-surefire) but I’m a bit hesitant to edit the pom.xml or do other configuration changes to make my tests pass, since I’m worried there is actually something wrong that I would be bypassing.

Since I haven’t worked too much with maven-integrated unit testing yet, I’m wondering what more experienced OpenMRS devs would suggest?

There is a possibility of interference from other tests. Does it pass if your run it with maven but as a single test class? http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html

1 Like

Yes, I get a success calling mvn -Dtest=ConceptValidatorTest test.

I can take a look if you can do a pull request with this failing test.

Done that!