lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: -ea assertions mismatch error when running JUnit test
Date Thu, 05 Jan 2017 17:39:14 GMT
: I am trying to switch from using the SolrJ Embedded Server to the
: SolrJettyTestBase in my Junit tests. However, I am getting the following
: error:
: 
: java.lang.Exception: Assertions mismatch: -ea was not specified but
: -Dtests.asserts=true
	...

: I reached out to the Solr User list, and they said that I need to either
: add "-ea" to the java commandline or remove the system property. The
: problem is that I didn’t specify the property and I’m not sure how to tell

... "tests.asserts" actaully defaults to "true" in the LuceneTestCase base 
class used by all Solr tests (that error mesg isn't the greatest, because 
it implies -D... was explicitly used, but it didn't have to me)

The simplest way to avoid this error is to ensure your tests are run with 
"-ea" ... but then you only ever test your code with assertions enabled 
(in the lucene/solr code base, we randomly decide as part of the test 
runner if/when to use assertions -- hence the extra property as a sanity 
check)

I'm not very familiar with maven, but from some quick googling it 
sounds like the "normal" way to run tests in maven is the 
"maven-surefire-plugin" and it has "enableAssertions" enabled by 
default? ... perhaps something about your pom is overriding that?  (i see 
"maven-failsafe-plugin" in your pom -- is that what's running your test? 
does it have an option to enable jvm assertions?)

If that approach doesn't work, the other option is to go the other 
direction and ignore the jvm assertions by forcing maven to set 
tests.asserts=false when invoking the test JVM.  Again, i don't know much 
about maven, but some random googling suggests you can configure the 
surefire plugin (assuming that's what you're using) to pass custom system 
properties to the JVMs it creates...

https://stackoverflow.com/questions/824019/maven-2-1-0-not-passing-on-system-properties-to-java-virtual-machine



-Hoss
http://www.lucidworks.com/

Mime
View raw message