Trying to create a conditional global teardown in test suite

Ask general questions here.
fester13579
Posts: 30
Joined: Thu Feb 13, 2014 10:29 pm

Trying to create a conditional global teardown in test suite

Post by fester13579 » Fri Apr 27, 2018 6:42 pm

With the help of the forum (https://www.ranorex.com/forum/post42342.html#p42342) I wrote some user code in a recording module to perform a snapshot within a teardown but only if the error counts are not 0.
rec module example .jpg
rec module example .jpg (34.65 KiB) Viewed 221 times
If I place the teardown at the test case level then the code works fine, but if I try to move it to a global teardown at the suite level I get an error. "Object variable or With block variable not set"
error example.jpg
error example.jpg (120.32 KiB) Viewed 221 times

Code: Select all

Public Sub CheckForFailuresThenSnapshot()
			
'HowTO: GeT ranorex error counts https://www.ranorex.com/forum/post42342.html#p42342 converted from C example
			
			Ranorex.Core.Reporting.TestReport.SaveReport()
			Dim SuiteACT As Object = Ranorex.Core.Reporting.TestReport.CurrentTestContainerActivity
			
			Dim blocked As Integer = SuiteACT.TotalBlockedCount
			Dim TC_blocked As Integer =CInt( SuiteACT.TotalBlockedTestCaseCount)
			
			Dim ErrorCT As Integer =CInt( SuiteACT.TotalErrorCount)
			
			Dim Failed As Integer = CInt(SuiteACT.TotalFailedCount)
			Dim TC_Failed As Integer = (SuiteACT.TotalFailedTestCaseCount)
			
			Dim SuccessCT As Integer = CInt(SuiteACT.TotalSuccessCount)
			Dim TC_SuccessCT As Integer = CInt(SuiteACT.TotalSuccessTestCaseCount)
			
			
			Dim msg As String ="Blocked:" & blocked.ToString() & "  TC_Blocked:" & TC_blocked.ToString() & "  ErrorCT:" & ErrorCT.ToString() 
			Msg &= "  Failed:"  & Failed.ToString() & "  TC_Failed:" & TC_Failed.ToString() & "  SuccessCT:" & SuccessCT.ToString()
			msg &= 			"  TC_SuccessCT:" & TC_SuccessCT.ToString()
			
			
			Report.Info("User",msg)
			
			
			If ErrorCT >0 Or TC_Failed >0 Or Failed >0 Then 
				Try ' do snapshot of OM DOM
					Report.Snapshot(ReportLevel.Info, "User", "", repo.DellOpenManage.Self, new RecordItemIndex(2)) ' OM DOM
				Catch ex As Exception
					Report.Log(ReportLevel.Warn, "Module", "(Optional Action) " & ex.Message, New RecordItemIndex(2))
				End Try
			End If
			
			
			
		End Sub
If I set breakpoints, it blows up on this line or the ones below it:

Code: Select all

Dim blocked As Integer = SuiteACT.TotalBlockedCount
I don’t understand the code enough to make it work as either part of a test case or at the global suite level.

Could someone please offer some pointers on this?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Trying to create a conditional global teardown in test suite

Post by odklizec » Mon Apr 30, 2018 8:03 am

Hi,

CurrentTestContainerActivity will not work at the test suite level ;) You must replace it with CurrentTestSuiteActivity! Hope this helps?
Last edited by odklizec on Mon Apr 30, 2018 3:24 pm, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

fester13579
Posts: 30
Joined: Thu Feb 13, 2014 10:29 pm

Re: Trying to create a conditional global teardown in test suite

Post by fester13579 » Mon Apr 30, 2018 3:18 pm

Thank you, that did it!!!