Skip to content

Commit

Permalink
HSEARCH-3892 Add some logging to tests for easier debugging of test s…
Browse files Browse the repository at this point in the history
…etup failures
  • Loading branch information
yrodiere committed Apr 15, 2020
1 parent 182fb97 commit 973e525
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -7,6 +7,7 @@
package org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -29,6 +30,8 @@
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration;
import org.hibernate.search.util.common.logging.impl.Log;
import org.hibernate.search.util.common.logging.impl.LoggerFactory;
import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider;
import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingIndexManager;
import org.hibernate.search.engine.cfg.spi.ConfigurationPropertySource;
Expand All @@ -47,6 +50,8 @@

public class SearchSetupHelper implements TestRule {

private final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() );

private final TestConfigurationProvider configurationProvider;
private final TckBackendSetupStrategy setupStrategy;
private final TestRule delegateRule;
Expand Down Expand Up @@ -106,6 +111,12 @@ public void evaluate() throws Throwable {
try {
base.evaluate();
}
catch (RuntimeException e) {
// When used as a @ClassRule, exceptions are not properly reported by JUnit.
// Log them so that we have something in the logs, at least.
log.warn( "Exception thrown by test and caught by SearchSetupHelper rule: " + e.getMessage(), e );
throw e;
}
finally {
cleanUp( closer );
}
Expand Down

0 comments on commit 973e525

Please sign in to comment.