Skip to content

Parser fails to throw InvalidXml exception on XML with < and > in text #11

@grndvl1

Description

@grndvl1

I use this to parse XML from JUnit files for Android UI tests. The ones that fail spit out in the XML a element that has a really long message about why the test failed with stack traces in Espresso testing. It contains multiple less than signs...

I have no control how Android UI tests spit out JUnit. How do I have it parse out the failure string and ignore this issue of less than. I remember somehow being able to do this many years ago but haven't touched XML in ages.

Example test fail: It will parse in order the first 3 but the last two won't be seen and no error happens either...

  <testcase name="saveAndUnsave" classname="SearchResultsRegressions" time="32.048"/>
  <testcase name="NoCallButton" classname="SearchResultsRegressions" time="0.001">
    <skipped/>
  </testcase>
  <testcase name="Call" classname="SearchResultsRegressions" time="30.647">
    <failure>androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (Child at position 0 in parent (view.getId() is <2131363167/debug:id/row_button_container> and Child at position 15 in parent (view.getId() is <2131363339/debug:id/rpConstraintLayout> and Child at position 0 in parent view.getId() is 2131363162/debug:id/rp_container>))) View Hierarchy: +>DecorView{id=-1, visibility=VISIBLE, width=1080, height=1920, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params={(0,0)(fillxfill) sim={adjust=pan} layoutInDisplayCutoutMode=shortEdges ty=BASE_APPLICATION wanim=0x10302fe fl=LAYOUT_IN_SCREEN LAYOUT_INSET_DECOR SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDS pfl=NO_MOVE_ANIMATION FORCE_DRAW_STATUS_BAR_BACKGROUND FIT_INSETS_CONTROLLED bhv=DEFAULT fitSides=}, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3} | +->LinearLayout{id=-1, visibility=VISIBLE, width=1080, height=1794, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@YYYYYY, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2} | +--</failure>
  </testcase>
  <testcase name="Splash_Displays" classname="SplashRegressions" time="0.002">
    <skipped/>
  </testcase>
  <testcase name="DP_Refresh_Banner" classname="dpRegressions" time="0.002">
    <skipped/>
  </testcase>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions