|
14 | 14 | import org.elasticsearch.test.cluster.ElasticsearchCluster; |
15 | 15 | import org.elasticsearch.test.junit.annotations.TestLogging; |
16 | 16 | import org.junit.ClassRule; |
| 17 | +import org.junit.runners.model.MultipleFailureException; |
17 | 18 |
|
18 | 19 | import java.io.IOException; |
19 | 20 | import java.util.Collections; |
20 | 21 |
|
| 22 | +import static org.hamcrest.Matchers.containsInAnyOrder; |
21 | 23 | import static org.hamcrest.Matchers.containsString; |
| 24 | +import static org.hamcrest.Matchers.hasSize; |
| 25 | +import static org.hamcrest.Matchers.hasToString; |
| 26 | +import static org.hamcrest.Matchers.instanceOf; |
22 | 27 |
|
23 | 28 | public class ESClientYamlSuiteTestCaseMultipleFailuresIT extends ESClientYamlSuiteTestCase { |
24 | 29 |
|
@@ -48,14 +53,17 @@ public void test() throws IOException { |
48 | 53 | try { |
49 | 54 | super.test(); |
50 | 55 | } catch (AssertionError error) { |
51 | | - String message = error.getMessage(); |
52 | | - assertThat("Error message should start with failure count", message, containsString("There were 3 errors")); |
53 | | - assertThat("Error message should contain first failure", message, containsString("wrong_value1")); |
54 | | - assertThat("Error message should contain second failure", message, containsString("wrong_value2")); |
55 | | - assertThat("Error message should contain third failure", message, containsString("wrong_value3")); |
56 | | - assertThat("Error message should contain actual value1", message, containsString("value1")); |
57 | | - assertThat("Error message should contain actual value2", message, containsString("value2")); |
58 | | - assertThat("Error message should contain actual value3", message, containsString("value3")); |
| 56 | + assertThat(error.getCause(), instanceOf(MultipleFailureException.class)); |
| 57 | + MultipleFailureException cause = (MultipleFailureException) error.getCause(); |
| 58 | + assertThat(cause.getFailures(), hasSize(3)); |
| 59 | + assertThat( |
| 60 | + cause.getFailures(), |
| 61 | + containsInAnyOrder( |
| 62 | + hasToString(containsString("wrong_value1")), |
| 63 | + hasToString(containsString("wrong_value2")), |
| 64 | + hasToString(containsString("wrong_value3")) |
| 65 | + ) |
| 66 | + ); |
59 | 67 | } |
60 | 68 | } |
61 | 69 |
|
|
0 commit comments