修复测试记录表格重试导致数据填充错乱问题。

This commit is contained in:
2024-04-19 21:24:55 +08:00
parent f1898a9280
commit ad2387c94c
7 changed files with 41 additions and 15 deletions

View File

@@ -237,6 +237,11 @@ Namespace UTSModule.Station
''' <returns></returns> ''' <returns></returns>
Public Property CanChangeLever() As Boolean Public Property CanChangeLever() As Boolean
''' <summary>
''' 当前节点是否处于重试状态
''' </summary>
''' <returns></returns>
Public Property IsRetry As Boolean
Private Sub AuthByType(type As RowTypeEnum) Private Sub AuthByType(type As RowTypeEnum)
Select Case type Select Case type

View File

@@ -22,6 +22,7 @@ Namespace UTSModule.Test.Command.SystemCommand
Public Overrides Function Execute() As TestCommandReturn Public Overrides Function Execute() As TestCommandReturn
Dim tester As UtsTester = UtsTester.CreateTester() Dim tester As UtsTester = UtsTester.CreateTester()
Dim rowNode As RowNode = tester.GetModule(_moduleName) Dim rowNode As RowNode = tester.GetModule(_moduleName)
rowNode.IsRetry = IsRetry
If rownode Is Nothing Then If rownode Is Nothing Then
CommandReturn.ExecuteResult = False CommandReturn.ExecuteResult = False

View File

@@ -6,6 +6,7 @@
Protected Property CommandReturn() As TestCommandReturn Protected Property CommandReturn() As TestCommandReturn
Public Property IsRetry As Boolean
Sub New(command As TestCommand) Sub New(command As TestCommand)
TestCommand = command TestCommand = command

View File

@@ -418,65 +418,67 @@ Namespace UTSModule.Test
' '
Me.CmsRecordGrid.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TsmiShowAllRows, Me.TsmiShowRecordRows, Me.TsmiBriefMode, Me.详细模式ToolStripMenuItem, Me.ToolStripSeparator1, Me.TsmiTestSetupNode, Me.TsmiTestCleanupNode, Me.ToolStripSeparator2, Me.TsmiTestNode, Me.TsmiStartTestWithNode}) Me.CmsRecordGrid.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TsmiShowAllRows, Me.TsmiShowRecordRows, Me.TsmiBriefMode, Me.详细模式ToolStripMenuItem, Me.ToolStripSeparator1, Me.TsmiTestSetupNode, Me.TsmiTestCleanupNode, Me.ToolStripSeparator2, Me.TsmiTestNode, Me.TsmiStartTestWithNode})
Me.CmsRecordGrid.Name = "ContextMenuStrip1" Me.CmsRecordGrid.Name = "ContextMenuStrip1"
Me.CmsRecordGrid.Size = New System.Drawing.Size(172, 192) Me.CmsRecordGrid.Size = New System.Drawing.Size(181, 214)
' '
'TsmiShowAllRows 'TsmiShowAllRows
' '
Me.TsmiShowAllRows.Name = "TsmiShowAllRows" Me.TsmiShowAllRows.Name = "TsmiShowAllRows"
Me.TsmiShowAllRows.Size = New System.Drawing.Size(171, 22) Me.TsmiShowAllRows.Size = New System.Drawing.Size(180, 22)
Me.TsmiShowAllRows.Text = "显示所有行" Me.TsmiShowAllRows.Text = "显示所有行"
' '
'TsmiShowRecordRows 'TsmiShowRecordRows
' '
Me.TsmiShowRecordRows.Name = "TsmiShowRecordRows" Me.TsmiShowRecordRows.Name = "TsmiShowRecordRows"
Me.TsmiShowRecordRows.Size = New System.Drawing.Size(171, 22) Me.TsmiShowRecordRows.Size = New System.Drawing.Size(180, 22)
Me.TsmiShowRecordRows.Text = "显示记录行" Me.TsmiShowRecordRows.Text = "显示记录行"
' '
'TsmiBriefMode 'TsmiBriefMode
' '
Me.TsmiBriefMode.Name = "TsmiBriefMode" Me.TsmiBriefMode.Name = "TsmiBriefMode"
Me.TsmiBriefMode.Size = New System.Drawing.Size(171, 22) Me.TsmiBriefMode.Size = New System.Drawing.Size(180, 22)
Me.TsmiBriefMode.Text = "简略模式" Me.TsmiBriefMode.Text = "简略模式"
' '
'详细模式ToolStripMenuItem '详细模式ToolStripMenuItem
' '
Me.详细模式ToolStripMenuItem.Name = "详细模式ToolStripMenuItem" Me.详细模式ToolStripMenuItem.Name = "详细模式ToolStripMenuItem"
Me.详细模式ToolStripMenuItem.Size = New System.Drawing.Size(171, 22) Me.详细模式ToolStripMenuItem.Size = New System.Drawing.Size(180, 22)
Me.详细模式ToolStripMenuItem.Text = "详细模式" Me.详细模式ToolStripMenuItem.Text = "详细模式"
' '
'ToolStripSeparator1 'ToolStripSeparator1
' '
Me.ToolStripSeparator1.Name = "ToolStripSeparator1" Me.ToolStripSeparator1.Name = "ToolStripSeparator1"
Me.ToolStripSeparator1.Size = New System.Drawing.Size(168, 6) Me.ToolStripSeparator1.Size = New System.Drawing.Size(177, 6)
' '
'TsmiTestSetupNode 'TsmiTestSetupNode
' '
Me.TsmiTestSetupNode.Name = "TsmiTestSetupNode" Me.TsmiTestSetupNode.Name = "TsmiTestSetupNode"
Me.TsmiTestSetupNode.Size = New System.Drawing.Size(171, 22) Me.TsmiTestSetupNode.Size = New System.Drawing.Size(180, 22)
Me.TsmiTestSetupNode.Text = "执行Setup模块" Me.TsmiTestSetupNode.Text = "执行Setup模块"
' '
'TsmiTestCleanupNode 'TsmiTestCleanupNode
' '
Me.TsmiTestCleanupNode.Name = "TsmiTestCleanupNode" Me.TsmiTestCleanupNode.Name = "TsmiTestCleanupNode"
Me.TsmiTestCleanupNode.Size = New System.Drawing.Size(171, 22) Me.TsmiTestCleanupNode.Size = New System.Drawing.Size(180, 22)
Me.TsmiTestCleanupNode.Text = "执行Cleanup模块" Me.TsmiTestCleanupNode.Text = "执行Cleanup模块"
' '
'ToolStripSeparator2 'ToolStripSeparator2
' '
Me.ToolStripSeparator2.Name = "ToolStripSeparator2" Me.ToolStripSeparator2.Name = "ToolStripSeparator2"
Me.ToolStripSeparator2.Size = New System.Drawing.Size(168, 6) Me.ToolStripSeparator2.Size = New System.Drawing.Size(177, 6)
' '
'TsmiTestNode 'TsmiTestNode
' '
Me.TsmiTestNode.Name = "TsmiTestNode" Me.TsmiTestNode.Name = "TsmiTestNode"
Me.TsmiTestNode.Size = New System.Drawing.Size(171, 22) Me.TsmiTestNode.Size = New System.Drawing.Size(180, 22)
Me.TsmiTestNode.Text = "选择项测试" Me.TsmiTestNode.Text = "选择项测试"
Me.TsmiTestNode.Visible = False
' '
'TsmiStartTestWithNode 'TsmiStartTestWithNode
' '
Me.TsmiStartTestWithNode.Name = "TsmiStartTestWithNode" Me.TsmiStartTestWithNode.Name = "TsmiStartTestWithNode"
Me.TsmiStartTestWithNode.Size = New System.Drawing.Size(171, 22) Me.TsmiStartTestWithNode.Size = New System.Drawing.Size(180, 22)
Me.TsmiStartTestWithNode.Text = "选择项开始测试" Me.TsmiStartTestWithNode.Text = "选择项开始测试"
Me.TsmiStartTestWithNode.Visible = False
' '
'SpcMain 'SpcMain
' '
@@ -1006,7 +1008,7 @@ Namespace UTSModule.Test
Me.SplitContainer1.Panel2.ResumeLayout(False) Me.SplitContainer1.Panel2.ResumeLayout(False)
CType(Me.SplitContainer1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.SplitContainer1, System.ComponentModel.ISupportInitialize).EndInit()
Me.SplitContainer1.ResumeLayout(False) Me.SplitContainer1.ResumeLayout(False)
Me.ResumeLayout(false) Me.ResumeLayout(False)
End Sub End Sub
Friend WithEvents StuState As System.Windows.Forms.StatusStrip Friend WithEvents StuState As System.Windows.Forms.StatusStrip

View File

@@ -371,6 +371,8 @@ Namespace UTSModule.Test
End With End With
End Sub End Sub
Private _lastNode As RowNode
''' <summary> ''' <summary>
''' 获取当前节点所在的记录行,0代表未找到对应节点 ''' 获取当前节点所在的记录行,0代表未找到对应节点
''' </summary> ''' </summary>
@@ -382,13 +384,17 @@ Namespace UTSModule.Test
row = _nodeList(node) row = _nodeList(node)
ElseIf _callNodeList.ContainsKey(node) Then ElseIf _callNodeList.ContainsKey(node) Then
If _callNodeUpdateCount.ContainsKey(node) Then If _callNodeUpdateCount.ContainsKey(node) Then
If _lastNode IsNot Nothing AndAlso _lastNode.RowListIndex <> node.RowListIndex AndAlso node.IsRetry = False Then
_callNodeUpdateCount(node) += 1 _callNodeUpdateCount(node) += 1
End If
Else Else
_callNodeUpdateCount.Add(node, 0) _callNodeUpdateCount.Add(node, 0)
End If End If
row = _callNodeList(node)(_callNodeUpdateCount(node)) row = _callNodeList(node)(_callNodeUpdateCount(node))
End If End If
_lastNode = node
Return row Return row
End Function End Function
@@ -476,6 +482,7 @@ Namespace UTSModule.Test
Public Sub ClearRecode() Public Sub ClearRecode()
If _grd Is Nothing Then Return If _grd Is Nothing Then Return
_lastNode = Nothing
_callNodeUpdateCount.Clear() _callNodeUpdateCount.Clear()
For row As Integer = 1 To _grd.Rows - 1 For row As Integer = 1 To _grd.Rows - 1
_grd.Cell(row, ColNames.Elapsed).Text = "" _grd.Cell(row, ColNames.Elapsed).Text = ""

View File

@@ -438,7 +438,9 @@ Namespace UTSModule.Test
Public Function ExecuteFixedModule(moduleName As FixedModuleEnum) As TestCommandReturn Public Function ExecuteFixedModule(moduleName As FixedModuleEnum) As TestCommandReturn
Dim result As TestCommandReturn Dim result As TestCommandReturn
If _testModules.ContainsKey(moduleName.ToString()) Then If _testModules.ContainsKey(moduleName.ToString()) Then
result = ExecutePlan(_testModules(moduleName.ToString()) Nothing) Dim node As RowNode = _testModules(moduleName.ToString())
node.IsRetry = False '顶级节点最初重试状态为false
result = ExecutePlan(node Nothing)
Else Else
result = New TestCommandReturn() result = New TestCommandReturn()
result.ExecuteResult = False result.ExecuteResult = False
@@ -579,6 +581,9 @@ Namespace UTSModule.Test
Dim p As Double = CDbl(IIf(retry = 0, 100, (node.Retry - retry) / node.Retry * 100)) Dim p As Double = CDbl(IIf(retry = 0, 100, (node.Retry - retry) / node.Retry * 100))
RaiseEvent RetryProgressChanged(Me, New TestProgressChangedEventArgs(p)) RaiseEvent RetryProgressChanged(Me, New TestProgressChangedEventArgs(p))
'判断节点是否为重试状态
If retry > 0 Then node.IsRetry = True
'重置模块测试结果 '重置模块测试结果
result.ExecuteResult = True result.ExecuteResult = True
@@ -586,6 +591,7 @@ Namespace UTSModule.Test
For Each rowNode As RowNode In node.RowNodes For Each rowNode As RowNode In node.RowNodes
If _exitTest Then Return GetExitTestReturn() '退出执行检测 If _exitTest Then Return GetExitTestReturn() '退出执行检测
rowNode.IsRetry = node.IsRetry '将父节点的重试状态赋予子节点
If ExecutePlan(rowNode, localVariable).ExecuteResult = False Then result.ExecuteResult = False '节点测试失败则认为模块失败 If ExecutePlan(rowNode, localVariable).ExecuteResult = False Then result.ExecuteResult = False '节点测试失败则认为模块失败
If result.ExecuteResult Then Continue For '执行成功则执行下一流程 If result.ExecuteResult Then Continue For '执行成功则执行下一流程
If TestFailMode = TestFailModeEnum.StepFail Then Exit For '单步失败模式下退出测试,不再执行 If TestFailMode = TestFailModeEnum.StepFail Then Exit For '单步失败模式下退出测试,不再执行
@@ -733,6 +739,10 @@ Namespace UTSModule.Test
Dim p As Double = CDbl(IIf(retry = 0, 100, (node.Retry - retry) / node.Retry * 100)) Dim p As Double = CDbl(IIf(retry = 0, 100, (node.Retry - retry) / node.Retry * 100))
RaiseEvent RetryProgressChanged(Me, New TestProgressChangedEventArgs(p)) RaiseEvent RetryProgressChanged(Me, New TestProgressChangedEventArgs(p))
'更新命令是否处于重试状态
If retry > 0 Then node.IsRetry = True
executor.IsRetry = node.IsRetry
'执行成功一次则判定成功,退出执行 '执行成功一次则判定成功,退出执行
result = executor.Execute() result = executor.Execute()
If result.ExecuteResult Then Exit For If result.ExecuteResult Then Exit For