You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When executing xmlPath query, without explicit setting root path , which starts with incorrect root node name I would expect to get a meaningful empty result.
Please consider the following test cases.
The first one shows correct behaviour for matching root element name.
The second one demonstrates incorrect, in my opinion, behaviour. Especially the last case, when the actual value of the firstName element is returned despite that wrong root is specified in the path.
For the other cases the whole xml tree is returned which also does not seem right for me.
After setting setRootPath("greeting") it behaves as expected.
Is this a desired behaviour? I have not found any documentation about this.
Or am I missing something?
Cheers,
Grzegorz
Tested with RestAssured version: 4.1.2
private static final String XML = "<greeting>" +
" <firstName>John</firstName>\n" +
" <lastName>Doe</lastName>\n" +
" </greeting>";
@Test // WORKS FINE
void should_get_result_for_matching_root_path() {
assertThat(new XmlPath(XML).get("greeting").toString()).isEqualTo("JohnDoe");
assertThat(new XmlPath(XML).get("greeting.firstName").toString()).isEqualTo("John");
}
@Test // FAILS FOR ALL ASSERTIONS
void should_get_meaningful_result_for_not_matching_root_path() {
// Whole xml is returned here
assertThat(new XmlPath(XML).get("notExisting").toString()).isBlank(); // Expecting blank but was:<"JohnDoe">
// Whole xml is returned here
assertThat(new XmlPath(XML).get("firstName").toString()).isBlank(); // Expecting blank but was:<"JohnDoe">
// Actual element value, despite wrong root path, is returned
assertThat(new XmlPath(XML).get("notExisting.firstName").toString()).isBlank(); // Expecting blank but was:<"John">
}
The text was updated successfully, but these errors were encountered:
When executing xmlPath query, without explicit setting root path , which starts with incorrect root node name I would expect to get a meaningful empty result.
Please consider the following test cases.
The first one shows correct behaviour for matching root element name.
The second one demonstrates incorrect, in my opinion, behaviour. Especially the last case, when the actual value of the
firstName
element is returned despite that wrong root is specified in the path.For the other cases the whole xml tree is returned which also does not seem right for me.
After setting
setRootPath("greeting")
it behaves as expected.Is this a desired behaviour? I have not found any documentation about this.
Or am I missing something?
Cheers,
Grzegorz
Tested with RestAssured version: 4.1.2
The text was updated successfully, but these errors were encountered: