当我在Visual Studio 2010 Premium中使用录像机录制测试时,我注意到录制器没有生成启动程序的代码。
重新制作的步骤:
考虑到启动程序是测试程序的一个相当重要的部分,我确信这个问题有解决方案。
答案 0 :(得分:2)
看看SO问题VS 2010 Coded UI Test - Launch Referenced Application
它可以回答你的问题。
答案 1 :(得分:0)
将此添加到您的UIMap.vb文件中:
(务必将EXE更改为与自己匹配)
Namespace RouteManagement_UI_Tests
Partial Public Class UIMap
Public Sub StartApp()
Dim RMS As ApplicationUnderTest = ApplicationUnderTest.Launch(Me.StartAppParams.ExePath, Me.StartAppParams.AlternateExePath)
End Sub
Public Overridable ReadOnly Property StartAppParams() As StartAppParams
Get
If (Me.mStartAppParams Is Nothing) Then
Me.mStartAppParams = New StartAppParams()
End If
Return Me.mStartAppParams
End Get
End Property
Private mStartAppParams As StartAppParams
End Class
Public Class StartAppParams
#Region "Fields"
'''<summary>
'''</summary>
Public ExePath As String = "C:\Somebinary.exe"
'''<summary>
'''</summary>
Public AlternateExePath As String = "%VisualStudioDir%\Somebinary.exe"
#End Region
End Class
End Namespace
然后在测试代码中引用此方法,如下所示:
Public Class CodedUITest1
<TestMethod()>
Public Sub Test1()
With Me.UIMap
.StartApp()
.ExitApp()
End With
End Sub
End Class