Advertisement
Md_Touhid

search for All Passing or failing Tests

Oct 4th, 2022 (edited)
1,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.82 KB | None | 0 0
  1. Imports System.Xml
  2.  
  3.  
  4. Module Program
  5.     Sub Main(args As String())
  6.         Dim doc As New XmlDocument()
  7.         doc.Load("SampleTrxXMLTestLogFile.trx")
  8.  
  9.         Console.WriteLine("1. Passed")
  10.         Console.WriteLine("2. Failed")
  11.         Console.WriteLine()
  12.         Console.Write("Enter 1 or 2 : ")
  13.  
  14.         Dim user_input As String = ""
  15.         Dim Search As String = 0
  16.         While (True)
  17.             user_input = Console.ReadLine()
  18.             If user_input = "1" Then
  19.                 Search = "Passed"
  20.                 Exit While
  21.             ElseIf user_input = "2" Then
  22.                 Search = "NotExecuted"
  23.                 Exit While
  24.             ElseIf user_input <> "1" AndAlso user_input <> "2" Then
  25.                 Console.WriteLine("Invalid Input!")
  26.                 Continue While
  27.             End If
  28.         End While
  29.  
  30.         Console.WriteLine()
  31.         Console.WriteLine()
  32.         Console.WriteLine("Searching for " + Search + "...")
  33.         Console.WriteLine()
  34.         Console.WriteLine()
  35.  
  36.         Dim nodeList As XmlNodeList = doc.DocumentElement.ChildNodes
  37.         For Each node As XmlNode In nodeList
  38.             If node.Name = "Results" Then
  39.                 Dim intValue1 As Integer = 0
  40.                 For Each node2 As XmlNode In node.ChildNodes
  41.                     If node2.Name = "UnitTestResult" AndAlso node2.Attributes("outcome").Value = Search Then
  42.                         Console.WriteLine("ID : " + node2.Attributes("testId").Value + " ---- " + "Title : " + node2.Attributes("testName").Value)
  43.                         Console.WriteLine()
  44.                         Console.WriteLine()
  45.                         intValue1 += 1
  46.                     End If
  47.                 Next
  48.                 Console.WriteLine(Search + " : " + intValue1.ToString)
  49.             End If
  50.         Next
  51.     End Sub
  52. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement