Commit b7043f14 authored by schrieveslaach's avatar schrieveslaach

Make IsolatedTestMojo more robost. Fixes #35

- IsolatedTestMojo logs failing calls of `runPipeline`.
- IsolatedTestMojo continues if a call of `runPipeline` fails.
parent 4824f79c
Pipeline #46884442 passed with stages
in 40 minutes and 15 seconds
......@@ -64,7 +64,7 @@ public class IsolatedToolsTestMojo extends AbstractTestMojo {
.forEach(TestResultWrapper::store);
}
@SneakyThrows({MojoExecutionException.class, UIMAException.class})
@SneakyThrows({MojoExecutionException.class})
private TestResultWrapper testNlpTool(AnalysisEngineDescription engineDescription, List<JCas> testData) {
logNlpToolsInfo(engineDescription);
......@@ -77,7 +77,12 @@ public class IsolatedToolsTestMojo extends AbstractTestMojo {
List<JCas> plainTestData = loadJCas(testReaderDescription);
for (JCas jCas : plainTestData) {
runPipeline(jCas, engineDescription);
try {
runPipeline(jCas, engineDescription);
} catch (UIMAException e) {
getLog().warn("Cannot test NLP tool " + analysisEngineService.getAnalysisEngineName(engineDescription) + " in isolation", e);
return null;
}
}
TestResult testResult = new TestResult(engineDescription);
......
......@@ -44,6 +44,7 @@ import static java.util.Arrays.asList;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.io.FileMatchers.anExistingFile;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
......@@ -156,6 +157,18 @@ public class IsolatedToolsTestMojoTest extends AbstractTestMojoTest {
assertThat(json, jsonEquals(jsonOpenNlpPersonTestResult()).withTolerance(0.001));
}
@Test
public void shouldContinueTestingIfSingleEngineDescriptionCannotBeTested() throws Exception {
AnalysisEngineDescription failingEngineDescription = createEngineDescription(OpenNlpNamedEntityRecognizer.class, ComponentParameters.PARAM_VARIANT, "abcdef-non-existing");
mockEngineDescriptionsInDescriptorsDirectory(failingEngineDescription);
provideTestJCas();
mojo.execute();
File directory = new File(folder.getRoot(), "target/isolated-tools-test-data/");
assertThat(directory.listFiles(), is(nullValue()));
}
@Override
protected AbstractTestMojo getMojoUnderTest() {
return mojo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment